statically compiling

Discussion in 'C++' started by fangee, Jan 18, 2007.

  1. fangee

    fangee Guest

    Hi everybody,
    I'm facing a problem trying to statically compile a simple c++ prog,
    something like:
    int main(){
    return 1;
    }

    Using g++ 2.95.4 (I must use this to compile a much more complex
    program) this way I get the following output:

    $ g++ -static tmp.cpp

    /usr/bin/../lib/libc.a(syslog.o): In function `__vsyslog_chk':
    (.text+0x6dd): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(syslog.o): In function `__vsyslog_chk':
    (.text+0x6f2): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(syslog.o): In function `openlog':
    (.text+0x803): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(syslog.o): In function `closelog':
    (.text+0x874): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(syslog.o):(.eh_frame+0x12): undefined
    reference to `__gcc_personality_v0'
    /usr/bin/../lib/libc.a(backtrace.o): In function `backtrace':
    (.text+0x54): undefined reference to `_Unwind_Backtrace'
    /usr/bin/../lib/libc.a(backtrace.o): In function `backtrace_helper':
    (.text+0x10a): undefined reference to `_Unwind_GetIP'
    /usr/bin/../lib/libc.a(backtrace.o): In function `backtrace_helper':
    (.text+0x12f): undefined reference to `_Unwind_GetGR'
    /usr/bin/../lib/libc.a(backtrace.o): In function `backtrace_helper':
    (.text+0x13a): undefined reference to `_Unwind_GetCFA'
    /usr/bin/../lib/libc.a(iofclose.o):(.eh_frame+0x11): undefined
    reference to `__gcc_personality_v0'
    /usr/bin/../lib/libc.a(iofflush.o): In function `fflush':
    (.text+0xdc): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(iofflush.o):(.eh_frame+0x12): undefined
    reference to `__gcc_personality_v0'
    /usr/bin/../lib/libc.a(iofwrite.o): In function `fwrite':
    (.text+0x126): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(iofwrite.o):(.eh_frame+0x12): undefined
    reference to `__gcc_personality_v0'
    /usr/bin/../lib/libc.a(wfileops.o): In function `_IO_wfile_underflow':
    (.text+0x125d): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(wfileops.o):(.eh_frame+0x12): undefined
    reference to `__gcc_personality_v0'
    /usr/bin/../lib/libc.a(fileops.o): In function `_IO_file_fopen':
    (.text+0x1f13): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(fileops.o): In function `_IO_file_underflow':
    (.text+0x2108): undefined reference to `_Unwind_Resume'
    /usr/bin/../lib/libc.a(fileops.o):(.eh_frame+0x12): undefined
    reference to `__gcc_personality_v0'
    collect2: ld returned 1 exit status

    Statically compiling the same program with g++ 4.1.2 all works fine.

    On my system (ubuntu linux 6.10 kernel 2.6.17-10-386) I've got the
    following libstdc++:
    /usr/lib/libstdc++-3-libc6.2-2-2.10.0.a
    /usr/lib/libstdc++-3-libc6.2-2-2.10.0.so
    /usr/lib/libstdc++.so.5.0.7
    /usr/lib/libstdc++.so.6.0.8

    Any suggestion?
    Thanks,
    f.
     
    fangee, Jan 18, 2007
    #1
    1. Advertisements

  2. Well, either you are not trying to compile the code given above, or you
    have some problem with your compiler, in which case you should turn to
    a newsgroup dedicated to that subject (gnu.g++.help).
     
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, Jan 18, 2007
    #2
    1. Advertisements

  3. fangee

    Lionel B Guest

    [snip more errors]
    [snip]

    You must be aware that g++ 2.95.x is pretty ancient and not terribly
    standards-compliant. That said, it looks as if the problem may be with
    your gcc 2.95.4 compiler setup and hence off-topic here (the C++ *code* is
    valid); I'd suggest asking on a newsgroup for your compiler/OS.

    Regards,
     
    Lionel B, Jan 18, 2007
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.