Unresolved Symbols from C++ Code

Discussion in 'C++' started by Scott Brady Drummonds, Oct 8, 2003.

  1. Hi, everyone,

    I'm writing a bunch of C++ code that is going to be linked into a program
    compiled with gcc (version 2.96; I have no option of changing this version).
    My C++ code compiles and executes without error in my C++ test harness.
    However, things fail once I move to gcc.

    Specifically, I'm getting errors like the following:

    vcs.o(.text+0xf): undefined reference to `operator new(unsigned)'
    vcs.o(.text+0x49): undefined reference to `operator delete(void*)'
    vcs.o(.text+0x5a): undefined reference to `_Unwind_Resume'
    vcs.o(.text+0x6b): undefined reference to `operator delete(void*)'
    vcs.o(.text+0xa9): undefined reference to `_Unwind_Resume'
    vcs.o(.text+0x149): undefined reference to
    `std::allocator<char>::allocator()'
    vcs.o(.text+0x15f): undefined reference to `std::string::string(char const*,
    std::allocator<char> const&)'
    vcs.o(.text+0x189): undefined reference to `std::string::~string()'
    vcs.o(.text+0x199): undefined reference to `std::string::~string()'
    vcs.o(.text+0x1ac): undefined reference to
    `std::allocator<char>::~allocator()'
    vcs.o(.text+0x1bc): undefined reference to
    `std::allocator<char>::~allocator()'
    ....
    /usr/users/home4/sdrummon/src/marple/src/vcs/libVCSMarple.a(vcs.o): In
    function `std::map<char const*, int, std::less<char const*>,
    std::allocator<std::pair<char const* const, int> > >::map()':
    vcs.o(.gnu.linkonce.t._ZNSt3mapIPKciSt4lessIS1_ESaISt4pairIKS1_iEEEC1Ev+0x4c
    ): undefined reference to `_Unwind_Resume'
    ....

    I have tried compiling the final binary (which uses both C and C++ compiled
    objects) with "-lstdc++". That fixes these issues on gcc 3.1, but causes
    the above problems with the 2.96. Perhaps another library needs to be added
    to the link line?

    Thanks!
    Scott

    --
    Remove ".nospam" from the user ID in my e-mail to reply via e-mail.
     
    Scott Brady Drummonds, Oct 8, 2003
    #1
    1. Advertising

  2. Scott Brady Drummonds

    Rolf Magnus Guest

    Scott Brady Drummonds wrote:

    > Hi, everyone,
    >
    > I'm writing a bunch of C++ code that is going to be linked into a
    > program compiled with gcc (version 2.96; I have no option of changing
    > this version). My C++ code compiles and executes without error in my
    > C++ test harness. However, things fail once I move to gcc.
    >
    > Specifically, I'm getting errors like the following:
    >
    > vcs.o(.text+0xf): undefined reference to `operator new(unsigned)'
    > vcs.o(.text+0x49): undefined reference to `operator delete(void*)'
    > vcs.o(.text+0x5a): undefined reference to `_Unwind_Resume'
    > vcs.o(.text+0x6b): undefined reference to `operator delete(void*)'
    > vcs.o(.text+0xa9): undefined reference to `_Unwind_Resume'
    > vcs.o(.text+0x149): undefined reference to
    > `std::allocator<char>::allocator()'
    > vcs.o(.text+0x15f): undefined reference to `std::string::string(char
    > const*, std::allocator<char> const&)'
    > vcs.o(.text+0x189): undefined reference to `std::string::~string()'
    > vcs.o(.text+0x199): undefined reference to `std::string::~string()'
    > vcs.o(.text+0x1ac): undefined reference to
    > `std::allocator<char>::~allocator()'
    > vcs.o(.text+0x1bc): undefined reference to
    > `std::allocator<char>::~allocator()'
    > ...
    > /usr/users/home4/sdrummon/src/marple/src/vcs/libVCSMarple.a(vcs.o): In
    > function `std::map<char const*, int, std::less<char const*>,
    > std::allocator<std::pair<char const* const, int> > >::map()':
    >

    vcs.o(.gnu.linkonce.t._ZNSt3mapIPKciSt4lessIS1_ESaISt4pairIKS1_iEEEC1E
    +0x4c
    > ): undefined reference to `_Unwind_Resume'
    > ...
    >
    > I have tried compiling the final binary (which uses both C and C++
    > compiled objects) with "-lstdc++".


    You mean s/compiling/linking/. Looks to me as if you're linking with gcc
    instead of g++.

    > That fixes these issues on gcc 3.1, but causes the above problems with

    the 2.96. Perhaps another library needs to be added to the link line?

    Maybe. Just use g++ for linking. This will automatically added
    everything that's needed.
     
    Rolf Magnus, Oct 8, 2003
    #2
    1. Advertising

  3. Well, after several hours of trial-and-error, I seem to have fixed this
    problem. I was compiling the C++ source with g++ 3.1 and that was getting
    linked to the C source using gcc 2.96. Early experiments suggest that
    backing the C++ compiler back to 2.96 fix the problem.

    I know it's academic at this point, but I'd like to know why the version
    imcompatibility caused the unresolved symbols mentioned below. Can someone
    explain?

    Scott

    "Scott Brady Drummonds" <> wrote in
    message news:bm1ps6$omj$...
    > Hi, everyone,
    >
    > I'm writing a bunch of C++ code that is going to be linked into a program
    > compiled with gcc (version 2.96; I have no option of changing this

    version).
    > My C++ code compiles and executes without error in my C++ test harness.
    > However, things fail once I move to gcc.
    >
    > Specifically, I'm getting errors like the following:
    >
    > vcs.o(.text+0xf): undefined reference to `operator new(unsigned)'
    > vcs.o(.text+0x49): undefined reference to `operator delete(void*)'
    > vcs.o(.text+0x5a): undefined reference to `_Unwind_Resume'
    > vcs.o(.text+0x6b): undefined reference to `operator delete(void*)'
    > vcs.o(.text+0xa9): undefined reference to `_Unwind_Resume'
    > vcs.o(.text+0x149): undefined reference to
    > `std::allocator<char>::allocator()'
    > vcs.o(.text+0x15f): undefined reference to `std::string::string(char

    const*,
    > std::allocator<char> const&)'
    > vcs.o(.text+0x189): undefined reference to `std::string::~string()'
    > vcs.o(.text+0x199): undefined reference to `std::string::~string()'
    > vcs.o(.text+0x1ac): undefined reference to
    > `std::allocator<char>::~allocator()'
    > vcs.o(.text+0x1bc): undefined reference to
    > `std::allocator<char>::~allocator()'
    > ...
    > /usr/users/home4/sdrummon/src/marple/src/vcs/libVCSMarple.a(vcs.o): In
    > function `std::map<char const*, int, std::less<char const*>,
    > std::allocator<std::pair<char const* const, int> > >::map()':
    >

    vcs.o(.gnu.linkonce.t._ZNSt3mapIPKciSt4lessIS1_ESaISt4pairIKS1_iEEEC1Ev+0x4c
    > ): undefined reference to `_Unwind_Resume'
    > ...
    >
    > I have tried compiling the final binary (which uses both C and C++

    compiled
    > objects) with "-lstdc++". That fixes these issues on gcc 3.1, but causes
    > the above problems with the 2.96. Perhaps another library needs to be

    added
    > to the link line?
    >
    > Thanks!
    > Scott
    >
    > --
    > Remove ".nospam" from the user ID in my e-mail to reply via e-mail.
    >
    >
     
    Scott Brady Drummonds, Oct 9, 2003
    #3
  4. > > I'm writing a bunch of C++ code that is going to be linked into a
    program
    > > compiled with gcc (version 2.96; I have no option of changing this

    > version).


    <snip>

    First, do not top-post. Second, do not include the whole message if you
    are only answering to parts of it (what's more, it was _your_ message).

    > I know it's academic at this point, but I'd like to know why the version
    > imcompatibility caused the unresolved symbols mentioned below. Can

    someone
    > explain?


    No, please post to the approriate forum.

    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9


    Jonathan
     
    Jonathan Mcdougall, Oct 9, 2003
    #4
    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. jozo
    Replies:
    1
    Views:
    2,297
    Ralf Hildebrandt
    May 16, 2004
  2. Andrew Mayo
    Replies:
    1
    Views:
    1,479
    Ryan Stewart
    Jan 31, 2005
  3. Jim
    Replies:
    0
    Views:
    353
  4. shouvik
    Replies:
    0
    Views:
    347
    shouvik
    Feb 11, 2008
  5. Replies:
    8
    Views:
    570
Loading...

Share This Page