undefined reference to '__gxx_personality_v0'

Discussion in 'C++' started by Albert Oppenheimer, Dec 9, 2005.

  1. I have a small program, test.c. It runs OK. This is on Linux (kernel
    2.6.8.1, GCC 3.4.1).

    I decided to convert it to C++ before expanding it to a larger program. I
    changed the filename to test.cpp and added

    extern "C" {
    }

    around main and all the non-static subroutines. It compiles OK, but when I
    link it, it says:

    test.o (.eh_frame+0x11): undefined reference to '__gxx_personality_v0'

    My program makes no reference to __gxx_personality_v0.

    What do I need to do to get this program to link as a C++ program?

    Thanks,
    Allie
    Albert Oppenheimer, Dec 9, 2005
    #1
    1. Advertising

  2. Albert Oppenheimer wrote:
    > I have a small program, test.c. It runs OK. This is on Linux (kernel
    > 2.6.8.1, GCC 3.4.1).
    >
    > I decided to convert it to C++ before expanding it to a larger program. I
    > changed the filename to test.cpp and added
    >
    > extern "C" {
    > }
    >
    > around main and all the non-static subroutines. It compiles OK, but when I
    > link it, it says:
    >
    > test.o (.eh_frame+0x11): undefined reference to '__gxx_personality_v0'
    >
    > My program makes no reference to __gxx_personality_v0.
    >
    > What do I need to do to get this program to link as a C++ program?


    This is platform specific, but try compiling (and linking) with "g++"
    rather than "gcc." Or, when you link, make sure you specify the C++
    library (which gcc does automatically if you use g++ as your command
    line rather than gcc).

    If you have further questions, you'll get better help asking in a
    platform-specific newsgroup.

    Best regards,

    Tom
    Thomas Tutone, Dec 9, 2005
    #2
    1. Advertising

  3. Albert Oppenheimer

    mlimber Guest

    Albert Oppenheimer wrote:
    > I have a small program, test.c. It runs OK. This is on Linux (kernel
    > 2.6.8.1, GCC 3.4.1).
    >
    > I decided to convert it to C++ before expanding it to a larger program. I
    > changed the filename to test.cpp and added
    >
    > extern "C" {
    > }
    >
    > around main and all the non-static subroutines. It compiles OK, but when I
    > link it, it says:
    >
    > test.o (.eh_frame+0x11): undefined reference to '__gxx_personality_v0'
    >
    > My program makes no reference to __gxx_personality_v0.
    >
    > What do I need to do to get this program to link as a C++ program?
    >
    > Thanks,
    > Allie


    The __gxx part indicates that this is a g++-specific implementation
    issue. The .eh_frame probably indicates that it is concerned with
    exception handling, code for which may be automatically inserted for
    C++ programs (but not for C). If so, you could disable exceptions with
    a compiler flag or link in the proper symbols from a library that came
    with your compiler (perhaps libstdc++?), which may not get pulled in
    with your current compiler flags. As the other respondent said, any
    follow-up should be directed to a GNU newsgroup see the FAQ for some
    alternate newsgroups:

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

    Cheers! --M
    mlimber, Dec 9, 2005
    #3
  4. Albert Oppenheimer

    Peter Most Guest

    Hello Albert,

    Albert Oppenheimer wrote:

    > I have a small program, test.c. It runs OK. This is on Linux (kernel
    > 2.6.8.1, GCC 3.4.1).
    >
    > I decided to convert it to C++ before expanding it to a larger program. I
    > changed the filename to test.cpp and added
    >

    This already enough to make it a C++ program. GCC will automatically compile
    it as a c++ program because of the cpp extension.

    > extern "C" {
    > }
    >
    > around main and all the non-static subroutines. It compiles OK, but when
    > I link it, it says:
    >

    It's not necessary. Remove the extern "C" stuff and try again, it should
    compile and link fine.
    You need the extern "C" only if you are calling a C function, like printf()
    from a C++ module. If you would like to know more, google for "name
    mangling" and you should find good explanations for it and what it's for.

    > test.o (.eh_frame+0x11): undefined reference to '__gxx_personality_v0'
    >
    > My program makes no reference to __gxx_personality_v0.
    >
    > What do I need to do to get this program to link as a C++ program?
    >
    > Thanks,
    > Allie


    hth Peter
    Peter Most, Dec 9, 2005
    #4
  5. Thanks, it linked and ran fine after I used g++.
    Albert Oppenheimer, Dec 9, 2005
    #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. Felipe
    Replies:
    3
    Views:
    445
    Felipe
    Jul 16, 2004
  2. Mantorok Redgormor
    Replies:
    70
    Views:
    1,753
    Dan Pop
    Feb 17, 2004
  3. Ken
    Replies:
    7
    Views:
    2,210
    Phil Carmody
    Sep 25, 2009
  4. VK
    Replies:
    45
    Views:
    591
    Dr John Stockton
    Sep 12, 2006
  5. -Lost
    Replies:
    13
    Views:
    370
    Richard Cornford
    Jan 31, 2007
Loading...

Share This Page