一、现象:

当在linux运行某软件或可执行程序时,偶尔会遇到缺库的情况,如下

ubuntu@test:~/install/sokit-1.3-linux32$ ./sokit 
./sokit: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory

二、解决办法

  1.使用ldd查找所有缺失的库文件,如下not found表示所缺库文件

ubuntu@test:~/install/sokit-1.3-linux32$ ldd sokit
	linux-gate.so.1 (0xf7fd5000)
	libQtGui.so.4 => not found
	libQtNetwork.so.4 => not found
	libQtCore.so.4 => not found
	libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf7f91000)
	libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf7dbf000)
	libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7cbd000)
	libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf7c9f000)
	libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7ac3000)
	/lib/ld-linux.so.2 (0xf7fd6000)

2.使用ldconfig工具查看系统中有无该库

ubuntu@test:~/install/sokit-1.3-linux32$ ldconfig -p | grep libQtGui
	libQtGui.so.4 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libQtGui.so.4

   如果没有可以去下面连接下载,然后进入第3步

https://ubuntu.pkgs.org/18.04/ubuntu-universe-amd64/libqtgui4_4.8.7+dfsg-7ubuntu1_amd64.deb.html

3.修改~/.bashrc, 将找到的库文件所在文件夹加入到环境变量

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/path

4.重新加载一下环境变量

source ~/.bashrc

5.OK,问题解决

Logo

更多推荐