Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Undefined virtual Function Table (http://www.velocityreviews.com/forums/t806079-undefined-virtual-function-table.html)

Brian 11-19-2011 09:30 PM

Undefined virtual Function Table
 
Hi,

I am currently working on a big project, and I usually don't post
to newsgroups as I like to get through problems on my own, or by
talking to coworkers. However, I have recently run across a problem
that I am unable to resolve using the tools that I have available:

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 have read that (On platforms that run neither collect nor the GNU
linker, like Solaris, you may see an odd undefined symbol like
"_vt.3foo",
where foo is a class name).

This is probably because you are missing a definition for the first
(non-inline) virtual function of the class. Since gcc-2.7.0, g++ uses
a trick borrowed from cfront: the .o file containing the definition
for the first non-inline virtual function for the class will also
contain the virtual function table.

I have also tried adding the -fvtable-thunks flag reccomended by
EGCS in dealing with missing virtual talbe problems. The problem
is that I am unable to build an executable while this symbol
remains undefined.

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
};

I have tried:
various code changes including making the destructor non-virtual,
not explicitly defined, removing inlining of code, inlining the
code, removing the destructor from the base class, and using nm to
tell us what line the symbol appears to be defined on. We have
tried using the gnu linker vs. the solaris linker, we have attempted
adding flags for inlining, and not inlining code for gcc, undefining
the symbol via flags [I was desperate]. Throughout all of this I
have been unable to either define this symbol, or make it go away.
And yes, I have read the available FAQ's and documentation.

Any help you can give me in resolving this problem would be greatly
appreciated, as I am at my wits end with this. Some things that are
not options at this time are: upgrading to an untested compiler,
combining the classes into one file, completely rewriting the code
from scratch, sacrificing small animals to solve the problem. We are
tied to this platform as well.

Thank you for your time and consideration in this matter.

Ian Collins 11-19-2011 09:35 PM

Re: Undefined virtual Function Table
 
On 11/20/11 10:30 AM, Brian wrote:
> Hi,
>
> I am currently working on a big project, and I usually don't post
> to newsgroups as I like to get through problems on my own, or by
> talking to coworkers. However, I have recently run across a problem
> that I am unable to resolve using the tools that I have available:
>
> 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'


Has this post taken a decade to reach Usenet? The tools and OS were old
when people where worrying about the millennium bug.

--
Ian Collins

Keith Thompson 11-19-2011 10:23 PM

Re: Undefined virtual Function Table
 
Brian <nospam@nospam.com> writes:
> I am currently working on a big project, and I usually don't post
> to newsgroups as I like to get through problems on my own, or by
> talking to coworkers. However, I have recently run across a problem
> that I am unable to resolve using the tools that I have available:
>
> 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'

[...]
> This is the basic code that I am working with:
> class OldClass

[...]
> };

[...]

Your code is C++, not C. You *might* get better answers in
comp.lang.c++.

But why are you using such ancient tools? gcc 2.8.1 was released
in 1998; the latest release is 4.6.2. Solaris 2.4 was released in
1994, and was superseded by Solaris 2.5 in 1995.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Seebs 11-19-2011 10:59 PM

Re: Undefined virtual Function Table
 
On 2011-11-19, Ian Collins <ian-news@hotmail.com> wrote:
> Has this post taken a decade to reach Usenet? The tools and OS were old
> when people where worrying about the millennium bug.


Doesn't one of the regular trolls frequently repost ages-old questions
that are obviously not about C here using the address nospam@nospam.com?

-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

Ian Collins 11-19-2011 11:25 PM

Re: Undefined virtual Function Table
 
On 11/20/11 11:59 AM, Seebs wrote:
> On 2011-11-19, Ian Collins<ian-news@hotmail.com> wrote:
>> Has this post taken a decade to reach Usenet? The tools and OS were old
>> when people where worrying about the millennium bug.

>
> Doesn't one of the regular trolls frequently repost ages-old questions
> that are obviously not about C here using the address nospam@nospam.com?


Indeed:

http://groups.google.com/group/comp....f055ecb09a845d


--
Ian Collins


All times are GMT. The time now is 02:05 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.