赞
踩
编写了一个使用GMP库的程序,编译可以通过,但是运行总是提示错误:
error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory.
在命令行查找libgmp.so.10
发现库文件存在,于是把该路径加到LD_LIBRARY_PATH,依旧无法执行。
去路径下查看,发现是快捷方式,于是运行下边的命令产看指向的文件:
ls -ltr /usr/local/lib/libgmp.so.10
打印结果表明指向文件存在。
看到查找共享库文件的方法:cat /etc/ld.so.conf
打印结果: include ld.so.conf.d/*.conf//说明文件中没有该库文件的路径,于是用echo命令将其加入文件中。
然后运行 ldd /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1//这条命令可能路径不到,关键是找cc1文件,可以用 find命令查找到路径,在执行这条指令
库文件应该存在于打印结果中,若是不存在,在运行 sudo ldconfig -v //将其添加,最后重新编译,文件可执行。
下边是操作的步骤和打印内容 可以参考
[ test]# ldd /usr/libexec/gcc/x86_64-redhat-linux/4.4.4/cc1
linux-vdso.so.1 => (0x00007ffffbdff000)
libmpfr.so.1 => /usr/lib64/libmpfr.so.1 (0x000000369f200000)
libgmp.so.3 => /usr/lib64/libgmp.so.3 (0x000000369fa00000)
libdl.so.2 => /lib64/libdl.so.2 (0x00000035f0e00000)
libc.so.6 => /lib64/libc.so.6 (0x00000035f1200000)
/lib64/ld-linux-x86-64.so.2 (0x00000035f0a00000)
[ test]# ./test
./test: error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory
[ test]# ldd /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/
cc1 cc1plus collect2 f951
[ test]# ldd /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1
linux-vdso.so.1 => (0x00007fff66ade000)
libmpfr.so.1 => /usr/lib64/libmpfr.so.1 (0x000000369f200000)
libgmp.so.3 => /usr/lib64/libgmp.so.3 (0x000000369fa00000)
libdl.so.2 => /lib64/libdl.so.2 (0x00000035f0e00000)
libc.so.6 => /lib64/libc.so.6 (0x00000035f1200000)
/lib64/ld-linux-x86-64.so.2 (0x00000035f0a00000)
[ test]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
[ test]# vi /etc/ld.so.conf
[ test]# echo "/usr/local/lib" >> /etc/ld.so.conf
[ test]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib
[ test]# ldd /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1
linux-vdso.so.1 => (0x00007fff217ff000)
libmpfr.so.1 => /usr/lib64/libmpfr.so.1 (0x000000369f200000)
libgmp.so.3 => /usr/lib64/libgmp.so.3 (0x000000369fa00000)
libdl.so.2 => /lib64/libdl.so.2 (0x00000035f0e00000)
libc.so.6 => /lib64/libc.so.6 (0x00000035f1200000)
/lib64/ld-linux-x86-64.so.2 (0x00000035f0a00000)
[ test]# sudo ldconfig -v
/usr/lib64/mysql:
libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
/usr/lib64/qt-3.3/lib:
libqt-mt.so.3 -> libqt-mt.so.3.3.8
libqui.so.1 -> libqui.so.1.0.0
/usr/lib64/xulrunner:
libmozsqlite3.so -> libmozsqlite3.so
libmozalloc.so -> libmozalloc.so
libxul.so -> libxul.so
libxpcom.so -> libxpcom.so
/usr/local/lib:
liblikwidpin.so -> liblikwidpin.so
libgmp.so.10 -> libgmp.so.10.2.0
/lib:
/lib64:
libnss_winbind.so.2 -> libnss_winbind.so.2
liblvm2app.so.2.2 -> liblvm2app.so.2.2
libplc4.so -> libplc4.so
libnss_wins.so.2 -> libnss_wins.so.2
libfipscheck.so.1 -> libfipscheck.so.1.1.0
libselinux.so.1 -> libselinux.so.1
libdevmapper-event-lvm2.so.2.02 -> libdevmapper-event-lvm2.so.2.02
libfreebl3.so -> libfreebl3.so
libgcrypt.so.11 -> libgcrypt.so.11.5.3
libgcc_s.so.1 -> libgcc_s-4.4.7-20120601.so.1
libdevmapper.so.1.02 -> libdevmapper.so.1.02
libnss_hesiod.so.2 -> libnss_hesiod-2.12.so
libply-splash-core.so.2 -> libply-splash-core.so.2.0.0
libresolv.so.2 -> libresolv-2.12.so
libm.so.6 -> libm-2.12.so
libnspr4.so -> libnspr4.so
libsepol.so.1 -> libsepol.so.1
libkrb5.so.3 -> libkrb5.so.3.3
libpam_misc.so.0 -> libpam_misc.so.0.82.0
libaio.so.1.0.0 -> libaio.so.1.0.0
libnss_sss.so.2 -> libnss_sss.so.2
libparted-2.1.so.0 -> libparted-2.1.so.0.0.0
libgobject-2.0.so.0 -> libgobject-2.0.so.0.2600.1
libss.so.2 -> libss.so.2.0
libcap.so.2 -> libcap.so.2.16
libldap_r-2.4.so.2 -> libldap_r-2.4.so.2.5.6
libz.so.1 -> libz.so.1.2.3
libip6tc.so.0 -> libip6tc.so.0.0.0-1.4.7
libmount.so.1 -> libmount.so.1.1.0
libSegFault.so -> libSegFault.so
libbz2.so.1 -> libbz2.so.1.0.4
libcidn.so.1 -> libcidn-2.12.so
libanl.so.1 -> libanl-2.12.so
librt.so.1 -> librt-2.12.so
libnl.so.1 -> libnl.so.1.1.4
libtirpc.so.1 -> libtirpc.so.1.0.10
libgpg-error.so.0 -> libgpg-error.so.0.5.0
libext2fs.so.2 -> libext2fs.so.2.4
libulockmgr.so.1 -> libulockmgr.so.1.0.1
libreadline.so.6 -> libreadline.so.6.0
libnih.so.1 -> libnih.so.1.0.0
liblvm2cmd.so.2.02 -> liblvm2cmd.so.2.02
libk5crypto.so.3 -> libk5crypto.so.3.1
libpthread.so.0 -> libpthread-2.12.so
ld-linux-x86-64.so.2 -> ld-2.12.so
libc.so.6 -> libc-2.12.so
libaudit.so.1 -> libaudit.so.1.0.0
libproc-3.2.8.so -> libproc.so
libBrokenLocale.so.1 -> libBrokenLocale-2.12.so
libauparse.so.0 -> libauparse.so.0.0.0
libxtables.so.4 -> libxtables.so.4.0.0-1.4.7
liblber-2.4.so.2 -> liblber-2.4.so.2.5.6
libldif-2.4.so.2 -> libldif-2.4.so.2.5.6
libdl.so.2 -> libdl-2.12.so
libpamc.so.0 -> libpamc.so.0.82.1
libncurses.so.5 -> libncurses.so.5.7
libcrypt.so.1 -> libcrypt-2.12.so
libgssrpc.so.4 -> libgssrpc.so.4.1
libutil.so.1 -> libutil-2.12.so
libpam.so.0 -> libpam.so.0.82.2
libdb-4.7.so -> libdb-4.7.so
libiw.so.29 -> libiw.so.29
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。