I have a debug version of libstdc++
6 in /usr/lib/debug/usr/lib/x86_64-linux-gnu/
.
I would like to tell gcc/g++ to use this library instead of the standard library version without debug symbols.
I tried using -nostdlib
and passing the library path explicitly with -L
, but get linking errors such as
/usr/bin/ld: CMakeFiles/tst_elfmap.dir/perfparser/tests/auto/elfmap/tst_elfmap.cpp.o: undefined reference to symbol '__gxx_personality_v0@@CXXABI_1.3' //usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
It seems that the library version (according to the file name) is the same for the debug and release builds of libstdc++ installed on my system:
lrwxrwxrwx 1 root 19 Oct 4 2019 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.21
Advertisement
Answer
You should make use of LD_LIBRARY_PATH
environment variable like:
export LD_LIBRARY_PATH=/usr/lib/debug/usr/lib/x86_64-linux-gnu/
This variable can be used to change the dynamic linkers search paths so, instead of searching for libstdc++
in the system’s library paths, libstdc++
will be searched along LD_LIBRARY_PATH
.