Re: Undefined reference to vtable

From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 11/19/04


Date: Fri, 19 Nov 2004 11:40:34 -0500

Karl Ebener wrote:
> I have created a program using several classes with inheritage. When I
> compile and link, I get the following error:
>
> :$ g++ service2.cpp Service.cpp Application.cpp Message.cpp
> MessageQueue.cpp MessageFragmenter.cpp SingleMessage.cpp
> /tmp/ccsrT4jU.o(.gnu.linkonce.t._ZN9c_ServiceD1Ev+0xb): In function
> `c_Service::~c_Service [in-charge]()':
> : undefined reference to `vtable for c_Service'
> /tmp/ccF4Q9O0.o(.text+0x27): In function
> `c_Service::c_Service[not-in-charge](long, bool)':
> : undefined reference to `vtable for c_Service'
> /tmp/ccF4Q9O0.o(.text+0x8b): In function
> `c_Service::c_Service[in-charge](long, bool)':
> : undefined reference to `vtable for c_Service'
> collect2: ld returned 1 exit status
>
> I think, I had this error once before, but I don't remember, what I did
> then. What is this vtable?

It's a way of implementing polymorphism, a table of pointers to virtual
member functions of the class.

> It is not an attribute of my classes.

Not explicitly, anyway.

>
> What's wrong??

Are you trying to call a virtual function from a constructor? Post your
code. A call to virtual function shouldn't go through vtable, though.
Do you have virtual functions? Just post your code.

V



Relevant Pages

  • Re: exportdll DLL
    ... way it can succeed is if you force a compile ... since an inline function doesn't really belong to any module; ... The virtual function issue is more interesting. ... Suppose you have the OP's class CMetaData: ...
    (microsoft.public.vc.mfc)
  • RE: [newbie][long]Pure virtual function call :(
    ... > I'm Visual C++ 6 newbie. ... I'm trying to compile some simple ... >: see declaration of 'QueryInterface' ... > virtual function was not defined ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Compile Error on Propputref
    ... > When i compile with this method it produces the following error ... But when i change propputref to propput it compiles ok. ... > cannot instantiate abstract class ... > virtual function was not defined ...
    (microsoft.public.vc.atl)
  • RE: [newbie][long]Pure virtual function call :(
    ... I'm trying to compile some simple ... >: see declaration of 'QueryInterface' ... > virtual function was not defined ... > pure virtual function was not defined ...
    (microsoft.public.dotnet.languages.vc)