undefined reference to typeinfo - C++ error message
2016-09-09 09:25
495 查看
undefined reference to typeinfo - C++ error message
There are some compiler and loader error messages that shout obviously
as to their cause, but there are others that simply don't give the new
user much of an indication as to what's really wrong. And most of those I
get to know pretty quickly, so that I can whip around a room during a
course, making suggestions to delegate to check for missing ; characters
or double quotes, to check that they have used the right type of
brackets for a list subscript and haven't unintentionally written a
function call, etc.
Here's one of the more obscure messages from the Gnu C++ compiler - or rather from the loader:
And you can be scratching you head for hour over that one!
The error? shape.o contains a base class from which classes are derived
in circle.o and square.o .. but virtual function(s) in shape's
definition are missing null bodies.
The fix? You've got line(s) like
that should read
这个错误解决了
There are some compiler and loader error messages that shout obviously
as to their cause, but there are others that simply don't give the new
user much of an indication as to what's really wrong. And most of those I
get to know pretty quickly, so that I can whip around a room during a
course, making suggestions to delegate to check for missing ; characters
or double quotes, to check that they have used the right type of
brackets for a list subscript and haven't unintentionally written a
function call, etc.
Here's one of the more obscure messages from the Gnu C++ compiler - or rather from the loader:
g++ -o polygon shape.o circle.o square.o polygon.o circle.o(.gnu.linkonce.r._ZTI6Circle+0x8): undefined reference to `typeinfo for Shape' square.o(.gnu.linkonce.r._ZTI6Square+0x8): undefined reference to `typeinfo for Shape' polygon.o(.gnu.linkonce.t._ZN5ShapeC2Ev+0x8): In function `Shape::Shape()': : undefined reference to `vtable for Shape' collect2: ld returned 1 exit status
And you can be scratching you head for hour over that one!
The error? shape.o contains a base class from which classes are derived
in circle.o and square.o .. but virtual function(s) in shape's
definition are missing null bodies.
The fix? You've got line(s) like
virtual float getarea() ;
that should read
virtual float getarea() {}
这个错误解决了
相关文章推荐
- undefined reference to typeinfo - C++ error message
- C++常见错误之error: 'XXX' does not name a type或undefined reference to `__glutInitWithExit'
- C++ 编译出现undefined reference to `vtable for Class 和 undefined reference to typeinfo for Class
- error: undefined reference to 'typeinfo for android::MediaSource' 错误解决
- error: undefined reference to 'typeinfo for FileDialogDelegate'
- C++ link error : undefined reference to 'vtable for ...'
- SharePoint 2013 Error - TypeError: Unable to get property 'replace' of undefined or null reference
- Eclipse c++ 中[Linker error] undefined reference to `WSAStartup@8'的解决办法
- C++ error:undefined reference to `XXX(XX)'
- LeetCodeBug-Runtime Error Message: reference binding to null pointer of type 'struct value_type'
- Linux c++ error: undefined reference to 'dlopen' 解决办法
- Undefined Reference to Typeinfo
- 【C++】Qt Creater网络编程,出现error: undefined reference to `_imp__WSAStartup@8
- DEV -C++ 中的 [Linker error] undefined reference to `__cpu_features_init' 错误
- Undefined Reference to Typeinfo
- undefined reference to `typeinfo for IA' collect2: ld returned 1 exit status
- win7下qt error: undefined reference to `_imp__getnameinfo@28'解决
- undefined reference to `typeinfo for QWidget'的解决
- Undefined Reference to Typeinfo
- Error:(32) android studio开发,报错undefined reference to `AndroidBitmap_getInfo'