无法加载存在于库搜索路径上的共享库
cannot load shared library which exist on the library search path
我正在尝试执行从源代码构建的 nft,但它报告
$ nft
nft: error while loading shared libraries: libnftnl.so.4: cannot open shared object file: No such file or directory
我通过运行 autogen.sh 从源代码构建了 libmnl、libnftnl、nftables,然后使用 :
配置
--prefix=/usr/local
这些是/usr/local/lib的内容:
$ ls -l /usr/local/lib/ | grep libnftnl
-rwxr-xr-x 1 root root 961 Mar 2 20:16 libnftnl.la
lrwxrwxrwx 1 root root 17 Mar 2 20:16 libnftnl.so -> libnftnl.so.4.0.0
lrwxrwxrwx 1 root root 17 Mar 2 20:16 libnftnl.so.4 -> libnftnl.so.4.0.0
-rwxr-xr-x 1 root root 913147 Mar 2 20:16 libnftnl.so.4.0.0
更多信息:
$ ldd $(which nft)
linux-vdso.so.1 => (0x00007ffd7afbf000)
libmnl.so.0 => /usr/lib/x86_64-linux-gnu/libmnl.so.0 (0x00007fc60181f000)
libnftnl.so.4 => not found
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007fc6015d8000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fc601364000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc600f9f000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fc600d75000)
/lib64/ld-linux-x86-64.so.2 (0x000055a0bd82d000)
我的 ld.so.conf 的内容是:
$ cat /etc/ld.so.conf
/usr/lib/x86_64-linux-gnu/libfakeroot
# libc default configuration
/usr/local/lib
/usr/local/lib/
# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/mesa-egl
/usr/lib/x86_64-linux-gnu/mesa
/usr/lib/i386-linux-gnu/mesa
# Legacy biarch compatibility support
/lib32
/usr/lib32
# Legacy biarch compatibility support
/libx32
/usr/libx32
但是如果我将 LD_LIBRARY_PATH 设置为“/usr/local/lib”:
$ export LD_LIBRARY_PATH=/usr/local/lib
$ ldd $(which nft)
linux-vdso.so.1 => (0x00007ffedf9b3000)
libmnl.so.0 => /usr/local/lib/libmnl.so.0 (0x00007fb58a033000)
libnftnl.so.4 => /usr/local/lib/libnftnl.so.4 (0x00007fb589e0b000)
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007fb589ba3000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fb58992f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb58956a000)
libmxml.so.1 => /usr/lib/libmxml.so.1 (0x00007fb58935b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb58913d000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fb588f14000)
/lib64/ld-linux-x86-64.so.2 (0x000055a827fb3000)
任何人都可以帮助为什么它找不到库,即使它存在于搜索路径中?
我忘了 运行 ldconfig ,正如@Petesh 所指出的。 运行nning ldconfig.
后问题得到解决
我正在尝试执行从源代码构建的 nft,但它报告
$ nft
nft: error while loading shared libraries: libnftnl.so.4: cannot open shared object file: No such file or directory
我通过运行 autogen.sh 从源代码构建了 libmnl、libnftnl、nftables,然后使用 :
配置--prefix=/usr/local
这些是/usr/local/lib的内容:
$ ls -l /usr/local/lib/ | grep libnftnl
-rwxr-xr-x 1 root root 961 Mar 2 20:16 libnftnl.la
lrwxrwxrwx 1 root root 17 Mar 2 20:16 libnftnl.so -> libnftnl.so.4.0.0
lrwxrwxrwx 1 root root 17 Mar 2 20:16 libnftnl.so.4 -> libnftnl.so.4.0.0
-rwxr-xr-x 1 root root 913147 Mar 2 20:16 libnftnl.so.4.0.0
更多信息:
$ ldd $(which nft)
linux-vdso.so.1 => (0x00007ffd7afbf000)
libmnl.so.0 => /usr/lib/x86_64-linux-gnu/libmnl.so.0 (0x00007fc60181f000)
libnftnl.so.4 => not found
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007fc6015d8000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fc601364000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc600f9f000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fc600d75000)
/lib64/ld-linux-x86-64.so.2 (0x000055a0bd82d000)
我的 ld.so.conf 的内容是:
$ cat /etc/ld.so.conf
/usr/lib/x86_64-linux-gnu/libfakeroot
# libc default configuration
/usr/local/lib
/usr/local/lib/
# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/mesa-egl
/usr/lib/x86_64-linux-gnu/mesa
/usr/lib/i386-linux-gnu/mesa
# Legacy biarch compatibility support
/lib32
/usr/lib32
# Legacy biarch compatibility support
/libx32
/usr/libx32
但是如果我将 LD_LIBRARY_PATH 设置为“/usr/local/lib”:
$ export LD_LIBRARY_PATH=/usr/local/lib
$ ldd $(which nft)
linux-vdso.so.1 => (0x00007ffedf9b3000)
libmnl.so.0 => /usr/local/lib/libmnl.so.0 (0x00007fb58a033000)
libnftnl.so.4 => /usr/local/lib/libnftnl.so.4 (0x00007fb589e0b000)
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007fb589ba3000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fb58992f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb58956a000)
libmxml.so.1 => /usr/lib/libmxml.so.1 (0x00007fb58935b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb58913d000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fb588f14000)
/lib64/ld-linux-x86-64.so.2 (0x000055a827fb3000)
任何人都可以帮助为什么它找不到库,即使它存在于搜索路径中?
我忘了 运行 ldconfig ,正如@Petesh 所指出的。 运行nning ldconfig.
后问题得到解决