Results 1 to 4 of 4

Thread: Strange undefined symbol error

  1. #1
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Strange undefined symbol error

    When I try to build my project with reference to a couple libraries, g++ tells me I don't have a definition for two functions: GC_pthread_join and GC_pthread_detach:

    The two libraries I am linking to are libracket.a and libmzgc.a. Both GC_pthread_join and GC_pthread_detach are defined in libmzgc.a.

    But the linker still balks:

    Undefined symbols:
    "_GC_pthread_join", referenced from:
    _mz_proc_thread_wait in libracket.a(mzrt.o)
    "_GC_pthread_detach", referenced from:
    _mz_proc_thread_detach in libracket.a(mzrt.o)

    When I peek inside libmzgc.a, I see a definition for GC_pthread_join and GC_pthread_detach. I am fairly sure I am linking this library in because the ensueing g++ linker command lists both of these libraries.

    My project file mentions them this way:

    LIBS += -L$$PLTSCHEME/lib -lmzgc -lracket

    If I change the names at all it tells me it could not find the libraries, so I'm fairly sure it tries to link them in.

    Any ideas? I feel like I am making some kind of a newbish mistake.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Strange undefined symbol error

    While the libraries may contain those functions, the linker might not be able to see them.

    One possible reason might be because the libraries you try to link to your application are themselves compiled/linked with another toolchain (compiler, linker, ...)
    Other compilers or linkers store the names of functions differently than the one you might be using.

    In other words, the compiler and linker you use expect those functions to have a certain name, but the actual name in the library might be different.

    This is only one possible reason of course.

  3. The following user says thank you to tbscope for this useful post:

    mhoover (1st November 2010)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Strange undefined symbol error

    Try reversing the order of libraries that get linked:
    qmake Code:
    1. LIBS += -L$$PLTSCHEME/lib -lracket -lmzgc
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    mhoover (1st November 2010)

  6. #4
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Strange undefined symbol error

    I was able to confirm the problem wasn't compiler mismatches or lib ordering (although I can see how that would manifest the errors I was seeing).

    It turns out the obscure scripting language I am stuck with uses two different garbage collectors (as if one garbage collector wasn't bad enough!). I had not installed the one I needed. After installing both it built and ran.

    Boo scheme. Boo racket.

Similar Threads

  1. Replies: 28
    Last Post: 28th July 2010, 21:25
  2. Replies: 1
    Last Post: 22nd June 2010, 20:56
  3. symbol lookup error
    By knishaq in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2010, 16:22
  4. QtPlugin and undefined symbol
    By Mikoskay in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2010, 13:04
  5. undefined symbol in library
    By quickNitin in forum General Programming
    Replies: 1
    Last Post: 16th November 2006, 11:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.