[c++] cannot open shared object file: No such file or directory

I met the share library not found on the head node of a cluster with torch. I have built the library as well as specify the correct path of the library while compiling my own program "absurdity" by g++. So it looks strange to me. Any idea? Thanks and regards!

[tim@user1 release]$ make  
...  
...  
g++ -pipe -W -Wall -fopenmp -ggdb3 -O2    -I/home/tim/program_files/ICMCluster/ann_1.1.1/include -I/home/tim/program_files/ICMCluster/libsvm-2.89  -I/home/tim/program_files/ICMCluster/svm_light  -o absurdity  xxxxxx.o  -L/home/tim/program_files/ICMCluster/ann_1.1.1/release/lib -L/home/tim/program_files/ICMCluster/libsvm-2.89/release/lib -L/home/tim/program_files/ICMCluster/svm_light/release/lib -lm -ljpeg -lpng -lz -lANN -lpthread -lsvm -lsvmlight  

[tim@user1 release]$ ./absurdity  
./absurdity: error while loading shared libraries: libsvmlight.so: cannot open shared object file: No such file or directory  

[tim@user1 release]$ ls /home/tim/program_files/ICMCluster/svm_light/release/lib/libsvmlight.so -l  
-rwxr-xr-x 1 tim Brown 121407 Jan 31 12:14 /home/tim/program_files/ICMCluster/svm_light/release/lib/libsvmlight.so 

[tim@user1 release]$ LD_LIBRARY_PATH= /home/tim/program_files/ICMCluster/svm_light/release/lib:$LD_LIBRARY_PAT    
[tim@user1 release]$ export LD_LIBRARY_PATH 

[tim@user1 release]$ ./absurdity  
./absurdity: error while loading shared libraries: libsvmlight.so: cannot open shared object file: No such file or directory  

[tim@user1 release]$ ls  /home/tim/program_files/ICMCluster/svm_light/release/lib  
libsvmlight.a  libsvmlight.so  

This question is related to c++

The answer is


sudo ldconfig

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib).

Generally package manager takes care of this while installing the new library, but not always (specially when you install library with cmake).

And if the output of this is empty

$ echo $LD_LIBRARY_PATH

Please set the default path

$ LD_LIBRARY_PATH=/usr/local/lib

Copied from my answer here: https://stackoverflow.com/a/9368199/485088

Run ldconfig as root to update the cache - if that still doesn't help, you need to add the path to the file ld.so.conf (just type it in on its own line) or better yet, add the entry to a new file (easier to delete) in directory ld.so.conf.d.


When working on a supercomputer, I received this error when I ran:

module load python/3.4.0
screen
python

To resolve the error, I simply needed to reload the module in the screen terminal:

module load python/3.4.0
python