![](/img/trans.png)
[英]How do I tell GCC not to link with the runtime library and the standard library?
[英]How can I ask GCC to use a different standard library?
我在/usr/lib/debug/usr/lib/x86_64-linux-gnu/
有一个libstdc++
6 的调试版本。 我想告诉 gcc/g++ 使用这个库而不是没有调试符号的标准库版本。 我尝试使用-nostdlib
并使用-L
显式传递库路径,但出现链接错误,例如
/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
对于安装在我的系统上的 libstdc++ 的调试和发布版本,库版本(根据文件名)似乎是相同的:
lrwxrwxrwx 1 root 19 Oct 4 2019 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.21
您应该使用LD_LIBRARY_PATH
环境变量,例如:
export LD_LIBRARY_PATH=/usr/lib/debug/usr/lib/x86_64-linux-gnu/
此变量可用于更改动态链接器搜索路径,因此,将沿LD_LIBRARY_PATH
搜索libstdc++
,而不是在系统的库路径中搜索libstdc++
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.