I have a c++ application which I am trying to build under Linux, it needs to be linked to a third party shared library, however this library has been built with a quite recent version of GCC/glibc (4.8.3/2.18). When I try and build my application using a less recent version of GCC/glibc (4.4.7/2.12), the linked phase of the build fails, with ld complaining of undefined references, which are references to functions defined in the newer libstdc++.
The third party has given me a precompiled version of libstdc++ and libgcc_s to use with the library, but how do I use these versions in my build?
How do I tell GCC to use the precompiled libraries instead of the system ones, while still using the system GCC?
I have tried using the "-nodefaultlibs" option and including "-lstdc++" and "-L" options, but it seems to have no effect on the undefined references.
Example of an error I get during linking:
undefined reference to std::__throw_bad_function_call()@GLIBCXX_3.4.14'
undefined reference to std::length_error::~length_error()@GLIBCXX_3.4.15'
I managed to get the application to build successfully by specifying the full path of the libstdc++ and libgcc_s shared objects in the objects list of the linking command (e.g. /home/mike/Downloads/libstdc++.so.6) . Going this way I didn't need to use any additional options such as "-nostdlibs" and only needed to ensure the linked shared objects were available via the LD_LIBRARY_PATH when running the application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With