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



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?



>    This is the basic code that I am working with:
>      class OldClass
>      { public:
>          OldClass() { /* some inlined code */ }
>          virtual ~OldClass () { }
>          virtual bool member_func();
>          virtual int* get_int ( int* id, int component_type) = 0;
>          virtual int  component2 (int id) = 0;
>       // other pure virtual functions similar to these exist
>      };
> 
> // 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,
there is no mention of where the constructor of the class is
implemented.  You understand that there would be a problem at link
time 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?  :-)


Hope this helps,


patrick@boxsoft.com


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