CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2007
    Posts
    34

    Linker Error Help

    Hi Everyone,
    In general what is the following linker error indicating?

    /app/lib/libXyz.so: undefined reference to `some_symbol'

    Using g++ compiler on Linux.

    I get multiple of these all with the same .so file but different undefined reference to part.

    I need help understanding the general meaning of this and maybe a link to something expalining the Linux build process.

    Thanks.
    Last edited by Yadrif; February 4th, 2009 at 08:35 AM.

  2. #2
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: Linker Error Help

    .so is a shared library, similar to .dll on windows. The linker is trying to find the .so file and cant find it. You need to make sure you have the file, and it is also where the linker expects to find it.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  3. #3
    Join Date
    Oct 2007
    Posts
    34

    Re: Linker Error Help

    Do you mean the linker is trying to find libXyz.so or the .so that the some_symbol is defined in?

    Thanks for your help.

  4. #4
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: Linker Error Help

    One of two things is happening. Either the linker cannot find the .so file, or else it finds it but the .so file doesn't export the functions you have used. So either you have a missing .so file or perhaps a wrong version .so file.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  5. #5
    Join Date
    Jan 2004
    Location
    Düsseldorf, Germany
    Posts
    2,401

    Re: Linker Error Help

    Libraries usually depend on other libraries. Let's say libxyz.so depends on libz.so you have to specify both libraries when linking (g++ -o prog *.o -lxyz -lz).

    If you do not specify all libraries, the linker will complain that symbols referenced in libxyz cannot be found. You can use the ldd command to understand what libraries libxyz.so depends on:

    Code:
    treuss>ldd /usr/lib/libpng12.so.0
            libz.so.1 => /usr/lib/libz.so.1 (0xb7fa6000)
            libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7f7f000)
            libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e3d000)
    So libpng12 depends on libz (and the standard libraries libc and libm).
    More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. --W.A.Wulf

    Premature optimization is the root of all evil --Donald E. Knuth


    Please read Information on posting before posting, especially the info on using [code] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured