Thursday, August 5, 2010

Cannot open shared object file

Ran into trouble trying to run an executable the other day. Hit the following message: cannot open shared object file: No such file or directory
Made sure that the shared object file in question actually did exist:
ls /lib | grep
ls /usr/lib | grep
 Turns out that the library was not in any of these standard directories, but existed in a separate directory. Made sure this separate directory was in the LD_LIBRARY_PATH:
The directory with the library was part of the load library path, but still no luck launching the executable. The runtime linker responsible for loading up the shared objects uses cached information about the objects rather than sifting through the directory structure. The cache information can be updated by running:
Running ldconfig crashed with a SIGBUS error. A little odd. Used the strace utility to list all the system calls made by ldconfig before the crash:
 strace ldconfig
The last "open" system call before the crash was to some random library I had never heard of or even used:
 open("/lib/", O_RDONLY)
Running the "file" command on this mysterious library reveals some deeper problems:
file /lib/
Solution: copied the same library over from another system and re-ran ldconfig.

In the end, was repaired and was perfectly fine. Retried the executable and it started up with no complaints.