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

这个错误解决了

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

  1. undefined reference to `typeinfo for xxx 报错

    编译成功了,链接的时候出现了这个报错 产生”undefined reference to `typeinfo for xxx’“最常见的原因就是基类的虚函数未实现了. 由于C++类的实现可以分布在多个 ...

  2. moc_XXXX.o:(.data.rel.ro._ZTI12CalculatorUI[_ZTI12CalculatorUI]+0x10): undefined reference to `typeinfo for QWidget' collect2: error: ld returned 1 exit status make: *** [Makefile:144: myCalculator]

    main.cpp:(.text.startup+0x22): undefined reference to `QApplication::QApplication(int&, char**, ...

  3. undefined reference to 'typeinfo for android::Thread'

    原因:工程使用了系统库libstagefright.so,而该库是Android系统用no-rtti方式编译出来的,因此我们的工程也必须要用no-rtti方式编译. 解决方法:在Application ...

  4. C++:undefined reference to vtable 原因与解决办法[转]

    [转]undefined reference to vtable 原因与解决办法 最近在写一套基础类库用于SG解包blob字段统计,在写完了所有程序编译时遇到一个郁闷无比的错误: MailBox.o( ...

  5. (.text+0x12): undefined reference to `rpl_fprintf'

    问题1:(.text+0x12): undefined reference to `rpl_fprintf'解决办法:在yacc前面添加%{#undef yyerrorvoid yyerror (ch ...

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

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

  7. undefined reference to `dlopen'

    g++ -O0 -g3 -I. -Ithird/json -Ithird/core/include -Ithird/vite/include -Ithird/openfst-1.2.10/src/in ...

  8. boost.numpy编译报错:undefined reference to `PyInt_FromLong' libboost_numpy.so: undefined reference to `PyCObject_AsVoidPtr'

    [ 31%] Built target boost_numpy[ 36%] Building CXX object libs/numpy/example/CMakeFiles/dtype.dir/dt ...

  9. gcc参数-l传递顺序错误导致`undefined reference'的一点小结

    刚才编译一个pthread的单文件程序, 使用的命令行是: gcc -o thread1 -lpthread thread1.c 结果报错: $ gcc -o thread1 -lpthread th ...

随机推荐

  1. Python学习(16)File(文件)方法

    Python File(文件) 方法 file 对象使用 open 函数来创建,下表列出了 file 对象常用的函数: 序号 方法及描述 1 file.close() 关闭文件.关闭后文件不能再进行读 ...

  2. iOS开发之 几本书

    <object_c 编程之道书> <iOS 7 UI Transition Guide> iOS开发指南:从零基础到App Store上架[国内第一本iOS架构设计图书,涵盖i ...

  3. Linux命令:traceroute(windows中为tracert)

    通过traceroute 我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路径.当然每次数据包由某一同样的出发点(source)到达某一同样的目的地(destination)走的路径可能会不 ...

  4. SDL2.0的几何图行绘画

    SDL2.0的几何图形绘画 通过SDL_Window.SDL_Renderer.SDL_Texture三者实现了简单的几何图形绘画. 包括了SDL_RenderDrawPoint.SDL_Render ...

  5. VI查找与替换

    一.vi查找:    当你用vi打开一个文件后,因为文件太长,如何才能找到你所要查找的关键字呢?在vi里可没有菜单-〉查找, 不过没关系,你在命令模式下敲斜杆(/)这时在状态栏(也就是屏幕左下脚)就出 ...

  6. C++ Primer 笔记(2)第二章 变量与基本类型

    第二章 变量与基本类型 1.基本内置类型包括算术类型和空类型,算术类型分为两类:整型(包括字符和布尔类型)和浮点型: 2.布尔类型(bool)的取值是真(true)或者假(false): 3.字面值常 ...

  7. Java调用Oracle存储过程过程中几个问题

    1.java.sql.SQLException: 无效的名称模式: STKSETTLEADMIN.TY_MARKETDATA 用户STKSETTLEADMIN下没有TY_MARKETDATA,类型TY ...

  8. VC++时间函数总结

    目录 第1章基本概念    1 1.1 基本概念    1 1.2 时间表示法    2 第2章 Win32 API    3 2.1 获取    3 2.1.1 时间间隔    3 2.1.2 时刻 ...

  9. cocos2dx从入门到精通课程

    一.移动开发基础 二.cocos2dx跨平台理论 三.cocos2dx框架 四.cocos2dx内存管理 五.cocos2dx的事件与消息机制 六.cocos2dx的定时器 七.cocos2dx的渲染 ...

  10. js将long日期格式转换为标准日期格式

    <script language="javascript"> //扩展Date的format方法 Date.prototype.format = function (f ...