This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Link errors related to vtable


On 16 January 2007 08:11, George wrote:

> Hi Dave,
> I am sorry as I am new to c++ I need more help in
> doing what you said is required.

  OK, step by step:

> -------------------------------------------------------
>>> g++ -O3 -Wall -I. -I.. -I../../../include -L. -L..
>>> -L../../../lib-linux -o run.x packet.o
>>> packet_generator.o hub.o main.o -lsystemc -lm 2>&1 | c++filt
>>> 
>> 
>
main.o:main.cpp:(.text$_ZN11packet_fifoC1EN7sc_core14sc_module_nameE[packet_fi
>> fo::packet_fifo(sc_core::sc_module_name)]+0x91):
>>> undefined reference to `VTT for packet_fifo'


  We have an undefined reference in main.o to the packet_fifo class vtable.
That means you have something in main.cpp, probably a function call to a
virtual function of class packet_fifo, that is trying to access the vtable and
it isn't being found at the link stage.

  So the questions you need answered are:

1.  Did the vtable get compiled by the compiler into any of the .o modules?
1a.  If yes, then why is it not being found at link-time?
1b.  If no, then where should it have been compiled and why wasn't it.

  You could answer question 1. by using 'nm' on the .o files to see whether
they contain the symbol for the vtable as seen in your error message above.
You could answer question 1a. by looking at the order of .o files in the link
command, references need to come before the things they refer to - maybe
main.o should move earlier in the list.  You could answer question 1b. by
reference to that section of the gcc manual I pointed at to see when and where
it should have been compiled and what condition for that it failed to meet.

  OTOH, I just put "undefined reference to VTT for" into google, and the very
first hit has this explanation:

http://www.centibyte.org/me/obscure-errors.html
The class [ ... ] has a virtual function (probably a destructor?) declared
that is not actually implemented. For example:


  So, did you forget to provide the implementation of a function that is
declared virtual in the class header file?


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]