Undefined virtual Function Table

Discussion in 'C Programming' started by Brian, Nov 19, 2011.

  1. Brian

    Brian Guest

    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.
    Brian, Nov 19, 2011
    #1
    1. Advertising

  2. Brian

    Ian Collins Guest

    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
    Ian Collins, Nov 19, 2011
    #2
    1. Advertising

  3. Brian <> 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) <http://www.ghoti.net/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Nov 19, 2011
    #3
  4. Brian

    Seebs Guest

    On 2011-11-19, Ian Collins <> 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 ?

    -s
    --
    Copyright 2011, all wrongs reversed. Peter Seebach /
    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.
    Seebs, Nov 19, 2011
    #4
  5. Brian

    Ian Collins Guest

    On 11/20/11 11:59 AM, Seebs wrote:
    > On 2011-11-19, Ian Collins<> 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 ?


    Indeed:

    http://groups.google.com/group/comp...fined virtual Function Table#85f055ecb09a845d


    --
    Ian Collins
    Ian Collins, Nov 19, 2011
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xiangliang Meng
    Replies:
    2
    Views:
    410
    Jack Klein
    Jun 21, 2004
  2. IK
    Replies:
    2
    Views:
    606
    hemraj
    Jul 23, 2004
  3. Ashwin
    Replies:
    2
    Views:
    345
    Pierre Barbier de Reuille
    Aug 1, 2006
  4. Replies:
    11
    Views:
    688
    James Kanze
    Sep 10, 2006
  5. gwowen
    Replies:
    6
    Views:
    316
    MikeWhy
    Jan 18, 2012
Loading...

Share This Page