Thursday, February 9, 2012

Solving "error while loading shared libraries" in Linux

For some newly compiled and installed programs in Linux, when they are executed for first time, the following error comes out

"error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or directory"
It happens in my Ubunutu Linux 11.10 box.

The solution is pretty simple.
1.)  Edit  /etc/ld.so.conf


sudo nano /etc/ld.so.conf


2.)  Add the path of the *.so, usually custom libraries are installed in  "/usr/local/lib", so adding this line can solve most of the problems.

3.) Save (of course) and execute

sudo /sbin/ldconfig –v

The problem is then solved.