I am trying to build TerraGear from the FlightGear project, and it needs multiple symbols from a static library libSimGearBucket
upon linking, for example SGBucket::gen_base_path
. ld
fails with
warning: undefined reference to »SGBucket::gen_base_path[abi:cxx11]() const
These are defined in the library:
$ nm libSimGearCore.a | grep gen_base_path
00000000000001f0 T _ZNK8SGBucket13gen_base_pathEv
U _ZNK8SGBucket13gen_base_pathEv
U _ZNK8SGBucket13gen_base_pathEv
I made triple sure that library is linked to the program needing the symbols. What is wrong ?
The function you need is SGBucket::gen_base_path[abi:cxx11]() const
.
The function you have is SGBucket::gen_base_path() const
. These aren't the same symbol.
You can use -Wl,--no-demangle
at link time to tell the linker to print mangled (real) symbol that ends up undefined, and that would make it clearer that you don't in fact have a definition of that symbol.
Possibly the libSimGearCore.a
library was compiled without -std=c++11
flag, while the code which needs the symbol was compiled with it.