This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: Undefined Virtual Function Table Using GCC 2.8.1


Patrick,


Thank you very much for the prompt response, I really appreciate it.  However,
the Constructor for newClass is defined in the cooresponding .C file for
newClass.  Forgetting to mention the existence of the constructor was an
oversight on our part, while trying to limit the amount of code that we
cluttered the mailing list with.   However both newClass and OldClass have
constructors.  It may be important to point out however that the OldClass
Constructor is inlined and the newClass Constructor is contained in the .C
implementation file.

patrick wrote:
>> // now, in a seperate file which compiles into a seperate object file
>> // but is included in the same static library we have:
>>
>>      class newClass : public OldClass
>>      { public:
>>          newClass();
>>          virtual ~newClass();  // this is implemented in the *.C file
>>        // no other virtual functions exist within this file
>>      };

>In your comment in `class newClass' you specify that the virtual
>destructor, ~newClass(), is implemented in the .C file.  However,
>here is no mention of where the constructor of the class is
>implemented.  You understand that there would be a problem at link
>ime since there seems to be no implementation of this method.

>If you do not need any special tasks performed at the construction
>of the object you could simply remove the reference to the constructor,
>newClass(), altogether:

>   class newClass : public OldClass
>  { public:
>     virtual ~newClass();  // this is implemented in the *.C file
>     // no other virtual functions exist within this file
 >  };
>
>or if you want it there:

>   class newClass : public OldClass
>  { public:
>       newClass() { /* nothing here */ };
>      virtual ~newClass();  // this is implemented in the *.C file
>   // no other virtual functions exist within this file
>   };

>Does this make any sence or am i totally off the wall here?  :-)


> Hello,
>
> I am not sure if i quite understand your problem, but I'll try and see
> if this simple thing i noticed in the code you provided is the bit causing
> your problem.
>
> First a question:
>
> >    While compiling an executable on the Sun-Solaris OS Version 2.4
> >    using gcc 2.8.1 and either the native sun linker or the ld that
> >    comes with binutils 2.9.1 we receive an undefined symbol:
> >      __vt_8NewClass  which demangles to 'TrackFiles virtual table'
>
> I am not exactly sure what you mean by the last sentence.  Could you
> explain it a bit please?

I'm sorry for the inexactness of this sentence, while writing up our
description of the problem, we changed the name of the symbol, but forgot to
change the name of what the symbol demangles to using the c++filt utility.
The line should actually read __vt_8NewClass which demangles to 'NewClass
virtual table' (the true name of newClass has been revealed :-).

Please let me know if I haven't provided enough explanation, or if you have
any questions regarding our explanation we are truly very eager to solve this
problem, and have been unable to do so after on our own.  I look forward to
your imput as this is proving to be very perplexing little  undefined symbol.

Thank You for the Time and Consideration,

James Warner & Dave Mictchell


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