Blog Ronald

Welcome to my Blog

undefined reference to typeinfo – C++ error message

Posted by T. Ronald S. on September 13, 2009

This error message made me scratching my head for hour

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

To fix this?

- undefined reference to typeinfo:
got this line? virtual float getarea() ;
that should read virtual float getarea() {} ;
- undefined reference to vtable means could be there is a virtual function from your interface is not implemented yet.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>