Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++: what are the causes of " undefined reference to 'typeinfo for [class name]' "other than virtual functions

Tags:

c++

some of these errors are solved by modifying

    virtual void draw();

to

    virtual void draw() {};

BUT, what can be the other causes of these errors?, other than virtual functions.. What can be the cause of the following error..

  /tmp/cciGEgp5.o:(.rodata._ZTI14CustomXmppPump[typeinfo for CustomXmppPump]+0x18): 
  undefined reference to `typeinfo for XmppPump'
like image 512
wolfgang Avatar asked Aug 10 '12 15:08

wolfgang


1 Answers

In GCC, the first non-inline virtual method is used to determine the the translation unit where the vtable and typeinfo objects are created. If you then do not define that method, it creates the error you see, since it expected you define that method somewhere, and was waiting for that definition to emit the output of the vtable and typeinfo for the class.

http://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html

When you change the declaration of virtual void draw(); to the inline definition of virtual void draw() {};, it picks a different function to emit the vtable.

like image 163
Dave S Avatar answered Oct 27 '22 04:10

Dave S