无法加载库搜索路径

时间:2016-03-02 16:08:43

标签: linux ld autoconf libtool netfilter

我试图执行nft,它是从源代码构建的,但是它会报告

 $ nft
nft: error while loading shared libraries: libnftnl.so.4: cannot open shared object file: No such file or directory

我通过runnning 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)

任何人都可以帮助它找不到库,即使它存在于搜索路径中吗?

1 个答案:

答案 0 :(得分:2)

我忘了运行ldconfig,正如@Petesh所指出的那样。运行ldconfig后问题得到解决。