gcc - / usr / bin / ld错误:无法找到< library>在/ usr / local / lib中通过ldconfig列出它,并将路径添加到ld.so.conf中 [英] gcc - /usr/bin/ld error: cannot find <library> in /usr/local/lib though ldconfig list it, and path added to ld.so.conf
问题描述
我尝试编译一个C ++代码,使用一个我也手动编译并安装在/ usr / local / lib中的库。
编译软件失败在链接步骤:
/ usr / bin / ld:error:找不到-lcppdb
$ b $ p似乎g ++在默认情况下不会在
/ usr / local / lib
,同样用于clang ++
g ++ -print-search-dirs#does不显示/ usr / local / lib
然而事实是
/ usr / local / lib
位于我的/etc/ld.so.conf
中,并且我运行了ldconfig
作为根,并且实际运行ldconfig -p | grep cppdb
显示我libcppdb_sqlite3.so.0(libc6)=> /usr/local/lib/libcppdb_sqlite3.so.0
libcppdb_sqlite3.so(libc6)=> /usr/local/lib/libcppdb_sqlite3.so
libcppdb.so.0(libc6)=> /usr/local/lib/libcppdb.so.0
libcppdb.so(libc6)=> /usr/local/lib/libcppdb.so
添加选项
-L / usr / local / lib
当然解决了这个问题,但目标是使用配置文件解决方案
p> ld
,链接器不为此使用外部配置文件。 ldconfig
用于加载程序, ld.so
。创建一个makefile,如果你想设置链接器的值。
I try to compile a C++ code, using a library I've also compiled manually and installed in /usr/local/lib
The compilation of the software fails at the linking step:
/usr/bin/ld: error: cannot find -lcppdb
it seems that g++ does not search by default in /usr/local/lib
, same for clang++
g++ -print-search-dirs # does not show /usr/local/lib
however the fact is /usr/local/lib
is in my /etc/ld.so.conf
and I did run ldconfig
as root, and actually running ldconfig -p | grep cppdb
shows me
libcppdb_sqlite3.so.0 (libc6) => /usr/local/lib/libcppdb_sqlite3.so.0
libcppdb_sqlite3.so (libc6) => /usr/local/lib/libcppdb_sqlite3.so
libcppdb.so.0 (libc6) => /usr/local/lib/libcppdb.so.0
libcppdb.so (libc6) => /usr/local/lib/libcppdb.so
adding the option -L/usr/local/lib
of course solve the problem, but the goal is to use configuration files
ld
, the linker, does not use external configuration files for that. ldconfig
is for the loader, ld.so
. Create a makefile if you want to set values for the linker somewhere.
这篇关于gcc - / usr / bin / ld错误:无法找到< library>在/ usr / local / lib中通过ldconfig列出它,并将路径添加到ld.so.conf中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!