我已经mpc
在自定义目录中安装了该库(以及其他库,但这是示例):
user@host /my/software/prefix $ l usr/lib | grep mpc
lrwxrwxrwx 1 user group 15 Mar 5 21:08 libmpc.so -> libmpc.so.3.0.0
lrwxrwxrwx 1 user group 15 Mar 5 21:08 libmpc.so.3 -> libmpc.so.3.0.0
-rwxr-xr-x 1 user group 96K Mar 5 21:08 libmpc.so.3.0.0
根据这个问题,我可以从链接器标志()中获取库的位置,-l<lib>
执行以下操作:
ld -lmpc --verbose
LD_LIBRARY_PATH=/my/software/prefix/usr/lib ld -lmpc --verbose
然而,结果是空的:
attempt to open /my/software/prefix/usr/x86_64-pc-linux-gnu/lib64/libmpc.so failed
attempt to open /my/software/prefix/usr/x86_64-pc-linux-gnu/lib64/libmpc.a failed
attempt to open /my/software/prefix/usr/lib/binutils/x86_64-pc-linux-gnu/2.2464/libmpc.so failed
attempt to open /my/software/prefix/usr/lib/binutils/x86_64-pc-linux-gnu/2.2464/libmpc.a failed
attempt to open /usr/local/lib64/libmpc.so failed
attempt to open /usr/local/lib64/libmpc.a failed
attempt to open /lib64/libmpc.so failed
attempt to open /lib64/libmpc.a failed
attempt to open /usr/lib64/libmpc.so failed
attempt to open /usr/lib64/libmpc.a failed
它甚至不搜索提供的路径LD_LIBRARY_PATH
。
这里出了什么问题?
答案1
将您的 /my/software/prefix/usr/lib 放入 /etc/ld.so.conf 并运行 sudo ldconfig。