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:

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() {}

这个错误解决了

时间: 2024-08-24 08:36:28

undefined reference to typeinfo - C++ error message的相关文章

【翻译自mos文章】在RHEL7或者OL7上安装11.2.0.4时遇到错误 “undefined reference to symbol ‘B_DestroyKeyObject’”

来源于: Installation of Oracle 11.2.0.4 on OL7 fails with "undefined reference to symbol 'B_DestroyKeyObject'" error (文档 ID 1965691.1) 适用于: Oracle Database - Enterprise Edition - Version 11.2.0.4 to 11.2.0.4 [Release 11.2] Oracle Database - Standar

Android编译错误——undefined reference to

[错误描述] 未定义引用 提示如下:bootable/recovery/minzip/Zip.c:1122: error: undefined reference to 'selabel_lookup'bootable/recovery/minzip/Zip.c:1123: error: undefined reference to 'setfscreatecon'bootable/recovery/minzip/Zip.c:1129: error: undefined reference to

错误 undefined reference to __cxa_guard_acquire/release

用gcc编译 c++ 程序时,出现错误 undefined reference to __cxa_guard_acquire linker error, 但是用icc可以正常编译, 问题出在static 上.从网上搜到的解决办法是加库的链接: To resolve this undefined references (__cxa_guard_acquire ) , add a library flag "-lstdc++" in your Makefile. It should wor

ubuntu系统下,gsl 库链接问题 -undefined reference to `cblas_xxx`

今天在ubuntu系统下进行程序调试的时候出现以下错误信息: [ 10%] Linking CXX executable ../test_coco /usr/local/lib/libgsl.so: undefined reference to `cblas_ztrsv' /usr/local/lib/libgsl.so: undefined reference to `cblas_scasum' /usr/local/lib/libgsl.so: undefined reference to

gcc/g++ undefined reference to function() 问题的解决方法

g++ 编译一个程序g++ shm.c -o shm, 用到了 shm_open(), shm_unlink()函数,编译出现了下面的错误: /tmp/ccL2cbha.o: In function `del_resource()': shm.c:(.text+0x1b3): undefined reference to `shm_unlink' /tmp/ccL2cbha.o: In function `main': shm.c:(.text+0x872): undefined referen

[Qt解错篇]报错:error: undefined reference to vtable for ClassName

一.问题描述: 编译工程时报错:error: undefined reference to vtable for ClassName,如图示: 二.问题分析: 造成这种错误的原因很多,甚至在纯C++编程过程中也可能出现.下面根据自己情况,具体问题具体分析. 原因:在原先没有Q_OBJECT关键字的工程中添加了该关键字,但是没有执行qmake,直接编译导致出现该错误. 三.例子: 原先工程的类建立: class CAppConfig { public: CAppConfig(void); CApp

error: undefined reference to 'property_set (转载)

转自:http://blog.csdn.net/u011589606/article/details/23474241 in the cpp file, please include #include <cutils/properties.h> in Android.mk, please add LOCAL_STATIC_LIBRARIES := \       libcutils \ error: undefined reference to 'property_set (转载)

jni/../../Classes/AppDelegate.cpp:102: error: undefined reference to &#39;TestController::TestController

<1>错误信息: [armeabi] SharedLibrary  : libcocos2dcpp.so E:/Android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/coc

win7下qt error: undefined reference to `[email&#160;protected]&#39;解决

[email protected]对应着winsock2.h的getnameinfo函数 首先需要导入对应的头文件 #ifndef WIN32 #include <sys/socket.h> #include <netinet/in.h> #else //win7下的头文件 #include <winsock2.h> #include<ws2tcpip.h> #endif 在qt的.pro工程文件中添加ws2_32.lib文件即可. LIBS += -lli