本文介绍了如何告诉gcc(或ld)链接到标准c和c ++库的调试版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有调试版本的libstdc ++和libc等等,并希望链接到他们。他们住在/ usr / lib / debug而不是/ usr / lib。任何想法?
解决方案
假设Linux,
- 静态库:向链接器命令行中添加
-L / usr / lib / debug
。gcc
/ld
将在默认系统目录之前查找。使用ldd
命令来验证是否链接了正确的库版本(仅限共享库)。 - 共享库:set
LD_LIBRARY_PATH = usr / lib / debug
,并且您的应用程序将从那里接收库,即使没有步骤1,只要有一个库的版本,这很可能是如果你正在安装
这是一个好主意,但是,因为一些库可能只是静态形式。 p>
I have debug versions of libstdc++ and libc, among others, and would like to link against them. They live in /usr/lib/debug as opposed to /usr/lib. Any ideas?
解决方案
Assuming Linux,
- Static libraries: add a
-L/usr/lib/debug
to your linker command line.gcc
/ld
will look there before default system directories. Useldd
command to verify that correct library versions were linked against (shared libraries only). - Shared libraries: set
LD_LIBRARY_PATH=usr/lib/debug
, and your application will pick up libraries from there even without step 1, as long as there is a version of a library, which is very likely if you are installing with distribution's package manager.
It's a good idea to do both, though, as some libraries may be only in static form.
这篇关于如何告诉gcc(或ld)链接到标准c和c ++库的调试版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!