错误解决error while loading shared libraries: libXXX.so.X: cannot open shared object file: No such file

分析原因:ld提示找不到库文件,而库文件就在当前目录中。 
链接器ld默认的目录是/lib和/usr/lib,如果放在其他路径也可以,需要让ld知道库文件在哪里。

方法1: 

切换到roo工作目录下
编辑/etc/ld.so.conf文件,在新的一行中加入库文件所在目录(如:/xxx/xxx/xxx);

运行ldconfig,以更新/etc/ld.so.cache文件;

方法2: 
在/etc/ld.so.conf.d/目录下新建任何以.conf为后缀的文件,在该文件中加入库文件所在的目录;

运行ldconfig,以更新/etc/ld.so.cache文件;

猜你喜欢

转载自www.cnblogs.com/tianzeng/p/9163447.html