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.
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.
Re: Strange undefined symbol error
Try reversing the order of libraries that get linked:
Code:
LIBS += -L$$PLTSCHEME/lib -lracket -lmzgc
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.