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. 【Todo】【读书笔记】机器学习实战(Python版)

    还是把这本书的读书笔记,单独拎出来吧,因为内容比较多. P38. Logistic 回归. 觉得还蛮实用的.囫囵吞枣看的.要细看.

  2. openfire消息通知推送

    package cn.zsmy.utils.openfire; import java.io.BufferedReader; import java.io.InputStreamReader; imp ...

  3. CSS三种定位机制

    标准文档流 块级元素撑满整个页面div,ul,li,dl,dt,p 行级元素可以一行显示多个span,strong,img,input大部分 一般不设置盒子的高度,另其自动调整 margin属性的au ...

  4. dede在线留言

    登录dede后台,在[核心]---[频道维护]---[自定义表单]中根据需要创建需要的表单.   点击[增加新的自定义表单],添加在线留言表单.确定即可. 注意: ①在这里只需要修改[自定义表单名称: ...

  5. 关于智能指针boost::shared_ptr

    boost库中的智能指针shared_ptr, 功能强大, 且开销小,故受到广大coder的欢迎. 但在实际的使用过程中,笔者也发现了一些不足. 1.定制的删除器 shared_ptr除了可以使用默认 ...

  6. Java位操作全面总结

    转载: Java位操作全面总结 在计算机中所有数据都是以二进制的形式储存的.位运算其实就是直接对在内存中的二进制数据进行操作,因此处理数据的速度非常快.在实际编程中,如果能巧妙运用位操作,完全可以达到 ...

  7. q和blockquote标签的区别

    q用来分离文本中的引语,定义一个短的引用.该标签会对引用的文本加双引号,一般情况很少用,博客论坛系统会用得多一些: blockquote用于对长文本的引用,用来定义一段引语,标签内的内容会自动有缩进: ...

  8. IDE显示无法打开源文件时解决方案

      解决方法:加上具体地址信息将 #include <qwidgetresizehandler_p.h> 改为 #include <C:\Users\INnoVation\Deskt ...

  9. (06)odoo报表

    ----------更新时间:18:06 2016-09-18 星期日18:13 2016-04-05 星期二10:31 2016-03-01 星期二----------* odoo8 采用是Qweb ...

  10. 《JavaScript权威指南》读书笔记(一)

    日期 2015-11-28 把之前的读书笔记在我弄丢它之前搬过来~~ 时间过去好久,回头一看理解都不一样了. 重点浏览了一下和Java的不同之处: js是一种宽松类型语言:js不区别整形数值与浮点型数 ...