C/C++ link problems

Discussion in 'C++' started by stephen henry, Sep 28, 2004.

  1. Hi all,

    Please help me...

    I have two projects: systemc (written in C++) and x264 (written in C).
    I would like to have a C++ project that that can call both systemc
    functions and x264 functions. What I've done is I've linked both
    libraries into my project, using an additional header file to include
    the C functions from x264 as follows:

    #ifndef __x264__h__
    #define __x264__h__

    extern "C" {

    #include "../x264/...";

    // include all the x264 headers here.

    }

    The project seems to compile fine, however when it gets to the linking
    stage it complains that it can't find a bunch of functions. What I'm
    having difficulty with is the fact that I'm using g++ (and explicitly
    linking in the stdc++ library) and the functions it can't find all
    relate to C++ functions, either in the standard library or in systemc.
    Previous usenet posts suggest that I may be using gcc opposed to g++,
    but, as my log shows, I am using the correct compiler. Even odder is
    the fact that it doesn't report that it can't find the x264 C
    functions I use (at least to my knowledge).

    When I run make I get (just a bit of the output):

    In file included from algorithm/x264/core/common.h:35,
    from algorithm/x264.h:15,
    from arch/src/camera.h:10,
    from arch/src/camg++ -Wno-deprecated -g -Wall -I.
    -I.. -I./algorithm -I./algorithm/core -I./algorithm/encoder In file
    included from algorithm/x264/core/common.h:35,
    from alg++ -Wno-deprecated -g -Wall -I. -I..
    -I./algorithm -I./algorithm/core -I./algorithm/encoder -Isystemc
    -I../common/systemc/include -L. -L.. -L../common/systemc/lib-linux
    -L./algorithm/x26../common/systemc/lib-linux/libsystemc.a(sc_main.o):
    In function `_GLOBAL__I_sc_in_action':
    sc_main.o(.text+0xc): undefined reference to
    `std::ios_base::Init::Init[in-charge]()'
    .../common/systemc/lib-linux/libsystemc.a(sc_main.o): In function
    `main':
    sc_main.o(.text+0x8b): undefined reference to `__cxa_begin_catch'
    sc_main.o(.text+0x92): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
    std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&)'
    sc_main.o(.text+0xa7): undefined reference to `std::cout'
    sc_main.o(.text+0xac): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
    <std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&, char const*)'
    sc_main.o(.text+0xb5): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
    <std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&, char const*)'
    sc_main.o(.text+0xbe): undefined reference to
    `std::basic_ostream<char, std::char_traits<char>
    >::eek:perator<<(std::basic_ostream<char, std::char_traits<char> >&

    (*)(std::basic_ostream<char, std::char_traits<char> >&))'
    sc_main.o(.text+0xc6): undefined reference to `__cxa_end_catch'
    sc_main.o(.text+0xd5): undefined reference to `__cxa_begin_catch'
    sc_main.o(.text+0xe4): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
    std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&)'
    sc_main.o(.text+0xf5): undefined reference to `std::cout'
    sc_main.o(.text+0xfa): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
    <std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&, char const*)'
    sc_main.o(.text+0x103): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
    <std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&, char const*)'
    sc_main.o(.text+0x10c): undefined reference to
    `std::basic_ostream<char, std::char_traits<char>
    >::eek:perator<<(std::basic_ostream<char, std::char_traits<char> >&

    (*)(std::basic_ostream<char, std::char_traits<char> >&))'
    sc_main.o(.text+0x117): undefined reference to `__cxa_begin_catch'
    sc_main.o(.text+0x11e): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
    std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&)'
    sc_main.o(.text+0x12f): undefined reference to `std::cout'
    sc_main.o(.text+0x134): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
    <std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&, char const*)'
    sc_main.o(.text+0x13d): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
    <std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&, char const*)'
    sc_main.o(.text+0x146): undefined reference to
    `std::basic_ostream<char, std::char_traits<char>
    >::eek:perator<<(std::basic_ostream<char, std::char_traits<char> >&

    (*)(std::basic_ostream<char, std::char_traits<char> >&))'
    sc_main.o(.text+0x153): undefined reference to `__cxa_end_catch'
    sc_main.o(.text+0x15c): undefined reference to `_Unwind_Resume'
    .../common/systemc/lib-linux/libsystemc.a(sc_main.o): In function
    `__tcf_0':
    sc_main.o(.text+0x3c): undefined reference to
    `std::ios_base::Init::~Init [in-charge]()'
    .../common/systemc/lib-linux/libsystemc.a(sc_main.o)(.gcc_except_table+0x2c):
    undefined reference to `typeinfo for char const*'
    .../common/systemc/lib-linux/libsystemc.a(sc_main.o)(.eh_frame+0x12):
    undefined reference to `__gxx_personality_v0'
    .../common/systemc/lib-linux/libsystemc.a(sc_simcontext.): In function
    `_GLOBAL__I__ZN16sc_process_tableC2Ev':
    sc_simcontext.(.text+0x19c): undefined reference to
    `std::ios_base::Init::Init[in-charge]()'
    .../common/systemc/lib-linux/libsystemc.a(sc_simcontext.): In function
    `sc_simcontext::crunch()':
    sc_simcontext.(.text+0x669): undefined reference to `_Unwind_Resume'
    sc_simcontext.(.text+0x69f): undefined reference to
    `__cxa_begin_catch'
    sc_simcontext.(.text+0x6a6): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
    std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&)'
    sc_simcontext.(.text+0x6bf): undefined reference to `std::cout'
    sc_simcontext.(.text+0x6c4): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
    <std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&, char const*)'
    sc_simcontext.(.text+0x6cd): undefined reference to
    `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
    <std::char_traits<char> >(std::basic_ostream<char,
    std::char_traits<char> >&, char const*)'
    sc_simcontext.(.text+0x6d6): undefined reference to
    `std::basic_ostream<char, std::char_traits<char>
    >::eek:perator<<(std::basic_ostream<char, std::char_traits<char> >&

    (*)(std::basic_ostream<char, std::char_traits<char> >&))'
    sc_simcontext.(.text+0x6e2): undefined reference to `__cxa_end_catch'


    Thanks for your help.

    Stephen
    stephen henry, Sep 28, 2004
    #1
    1. Advertising

  2. stephen henry wrote:
    > [...]


    <offtopic>
    Link errors, especially "unresolved externals" or "undefined
    references", are almost always due to the fact that some
    library file is missing from the list of libraries supplied
    to the linker. As I encountered recently, UNIX linkers are
    single-pass, so, if you have two libraries referring to each
    other, you need to mention those libraries twice. Make sure
    you have all necessary libraries mentioned and in the right
    order.
    </offtopic>

    Link errors have very little to do with the language. Please
    post your further inquiries to a newsgroup that deals with
    your compiler. gnu.g++.help seems right.

    V
    Victor Bazarov, Sep 28, 2004
    #2
    1. Advertising

  3. stephen henry

    Evan Carew Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Stephen,

    Could you tell us what your link line looked like?

    Evan

    stephen henry wrote:
    > Hi all,
    >
    > Please help me...
    >
    > I have two projects: systemc (written in C++) and x264 (written in C).
    > I would like to have a C++ project that that can call both systemc
    > functions and x264 functions. What I've done is I've linked both
    > libraries into my project, using an additional header file to include
    > the C functions from x264 as follows:
    >



    Evan
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.0.6 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFBWhbyoo/Prlj9GScRAsFAAJ94KkfYpLRYimfi67IXQri1UlPujQCfQh9u
    6DnvTqw+q+58aCBKRzjHoV0=
    =cJrl
    -----END PGP SIGNATURE-----
    Evan Carew, Sep 29, 2004
    #3
    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. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    810
    Kevin Spencer
    May 17, 2005
  2. Graham Thomson
    Replies:
    3
    Views:
    460
    Eki Y. Baskoro
    Dec 18, 2003
  3. Dan M
    Replies:
    5
    Views:
    420
  4. kolesdz
    Replies:
    9
    Views:
    527
    Blinky the Shark
    Aug 22, 2007
  5. Marina Limeira

    LINK with another link

    Marina Limeira, Feb 7, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    112
    Marina Limeira
    Feb 7, 2006
Loading...

Share This Page