当前位置: 技术问答>linux和unix
编译通过了,运行时找不到动态库,which能够找到
来源: 互联网 发布时间:2017-03-22
本文导语: [root@192 pdmlreader]# ./pdmlreader -h ./pdmlreader: error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory [root@192 pdmlreader]# which libpcap.so.1 /usr/local/lib/libpcap.so.1 [root@192 pdmlreader]# ldd...
[root@192 pdmlreader]# ./pdmlreader -h
./pdmlreader: error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory
[root@192 pdmlreader]# which libpcap.so.1
/usr/local/lib/libpcap.so.1
[root@192 pdmlreader]# ldd pdmlreader
linux-gate.so.1 => (0x00110000)
libnbee.so => /root/test/netbee/samples/nbee/pdmlreader/../../../bin/libnbee.so (0x00111000)
libpcap.so.1 => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x069ab000)
libm.so.6 => /lib/libm.so.6 (0x00661000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00d43000)
libc.so.6 => /lib/libc.so.6 (0x004f6000)
libxerces-c.so.28 => /usr/local/lib/libxerces-c.so.28 (0x0068a000)
libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x00164000)
libdl.so.2 => /lib/libdl.so.2 (0x00182000)
libpcap.so.1 => /usr/local/lib/libpcap.so.1 (0x00187000)
libnbprotodb.so => /root/test/netbee/src/nbprotodb/libnbprotodb.so (0x001bd000)
libnbpflcompiler.so => /root/test/netbee/src/nbpflcompiler/libnbpflcompiler.so (0x00d51000)
libnbsockutils.so => /root/test/netbee/src/nbsockutils/libnbsockutils.so (0x001e8000)
libnbnetvm.so => /root/test/netbee/src/nbnetvm/libnbnetvm.so (0x001ec000)
/lib/ld-linux.so.2 (0x004d6000)
libpthread.so.0 => /lib/libpthread.so.0 (0x002de000)
[root@192 pdmlreader]#
./pdmlreader: error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory
[root@192 pdmlreader]# which libpcap.so.1
/usr/local/lib/libpcap.so.1
[root@192 pdmlreader]# ldd pdmlreader
linux-gate.so.1 => (0x00110000)
libnbee.so => /root/test/netbee/samples/nbee/pdmlreader/../../../bin/libnbee.so (0x00111000)
libpcap.so.1 => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x069ab000)
libm.so.6 => /lib/libm.so.6 (0x00661000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00d43000)
libc.so.6 => /lib/libc.so.6 (0x004f6000)
libxerces-c.so.28 => /usr/local/lib/libxerces-c.so.28 (0x0068a000)
libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x00164000)
libdl.so.2 => /lib/libdl.so.2 (0x00182000)
libpcap.so.1 => /usr/local/lib/libpcap.so.1 (0x00187000)
libnbprotodb.so => /root/test/netbee/src/nbprotodb/libnbprotodb.so (0x001bd000)
libnbpflcompiler.so => /root/test/netbee/src/nbpflcompiler/libnbpflcompiler.so (0x00d51000)
libnbsockutils.so => /root/test/netbee/src/nbsockutils/libnbsockutils.so (0x001e8000)
libnbnetvm.so => /root/test/netbee/src/nbnetvm/libnbnetvm.so (0x001ec000)
/lib/ld-linux.so.2 (0x004d6000)
libpthread.so.0 => /lib/libpthread.so.0 (0x002de000)
[root@192 pdmlreader]#
|
PATH 是命令查找的路径,跟链接库没关系
/etc/ld.so.conf这个文件里定义查找库的目录
把/usr/local/lib/加到/etc/ld.so.conf文件内
ldconfig使其生效就行了
/etc/ld.so.conf这个文件里定义查找库的目录
把/usr/local/lib/加到/etc/ld.so.conf文件内
ldconfig使其生效就行了
|
方法一:
执行程序前,配一下库的搜寻路径
export LD_LIBRARY_PATH=/usr/local/lib/
方法二:
检查一下/etc/ld.so.conf.d/里的conf文件,看是否有包含/usr/local/lib
有的话,直接sudo ldconfig更新系统;没有的话把它加进去,然后再更新。
执行程序前,配一下库的搜寻路径
export LD_LIBRARY_PATH=/usr/local/lib/
方法二:
检查一下/etc/ld.so.conf.d/里的conf文件,看是否有包含/usr/local/lib
有的话,直接sudo ldconfig更新系统;没有的话把它加进去,然后再更新。
|
楼上说的对,你看看Path中包括这个路径没