首页 > 代码库 > 动态链接库找不到 : error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

动态链接库找不到 : error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

问题:

运行gsl(GNU scientific Library)的函数库,用

gcc erf.c -I/usr/local/include -L/usr/local/lib64 -L/usr/local/lib -g -Wall --std=gnu99 -lgsl -lgslcblas -o m.o

编译,之后运行./m.o

提示error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

 

解决方法:

在shell下

ldd m.o

输出:

~/test/c $ldd m.o 
linux-vdso.so.1 => (0x00007fff3d5ff000) 
libgsl.so.0 => not found 
libgslcblas.so.0 => not found 
libc.so.6 => /lib64/libc.so.6 (0x00007f7420c3b000) 
/lib64/ld-linux-x86-64.so.2 (0x00007f7420fdd000)

说明libgsl和libgslcblas.so找不到

 

sudo ldconfig

ldconfig的作用是:Configure Dynamic Linker Run Time Bindings.

然后再次运行ldd m.o

~/test/c $ldd m.o 
linux-vdso.so.1 => (0x00007fff62bad000) 
libgsl.so.0 => /usr/local/lib/libgsl.so.0 (0x00007f6968a01000) 
libgslcblas.so.0 => /usr/local/lib/libgslcblas.so.0 (0x00007f69687ce000) 
libc.so.6 => /lib64/libc.so.6 (0x00007f6968439000) 
libm.so.6 => /lib64/libm.so.6 (0x00007f69681b5000)

已经成功运行

 

问题出现原因:

刚刚安装好gsl后,由于gsl的动态链接库没有及时刷新导致识别不到。