Debugging load library path issues

If you get a problem with a library that can't find another, you should check the library's dependencies and make sure that the directory in which the missing library resides is part of the load library path.

One example of this problem, that I experienced recently, occurred when the library was unable to open the library. The error message was as follows:

Can't load '/usr/lib/perl5/site_perl/5.8.7/i686-linux/auto/Image/Magick/' for module Image::Magick: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.7/i686-linux/ line 230. at (eval 113) line 1 Compilation failed in require at (eval 113) line 1. BEGIN failed--compilation aborted at (eval 113) line 1.

Find out library dependencies with ldd

The ldd command will check the dependencies of a library.

ldd /the/library/path/

Using the above example problem:

username@localhost [~]# ldd /usr/lib/perl5/site_perl/5.8.7/i686-linux/auto/Image/Magick/ => not found => /usr/lib/ (0x0099a000) => /usr/lib/ (0x00111000) => /usr/lib/ (0x00121000) => /usr/lib/ (0x00d54000) => /usr/X11R6/lib/ (0x001f4000) => /usr/X11R6/lib/ (0x0016e000) => /usr/X11R6/lib/ (0x00910000) => /usr/X11R6/lib/ (0x0039d000) => /usr/X11R6/lib/ (0x005bc000) => /lib/tls/ (0x004cc000) => /lib/tls/ (0x00216000) => /lib/tls/ (0x00bda000) => /lib/ (0x00177000)
        /lib/ (0x002c2000)

You can see in that the library was not found.

Locate the library with find or locate or slocate or by any other means

Find the location of the library that couldn't be found by ldd. The chances are that the library will be in a subdirectory of /usr. Continuing with the above example...

username@localhost [~]# find /usr -name ""

Add the library to the load library path with ldconfig

In the words of the man page, ldconfig will configure dynamic linker run time bindings. Add your missing library to the bindings with the following command:

ldconfig /path/to/add

For our libMagick example, this would be:

username@localhost [~]# ldconfig /usr/local/lib

You can see a list of librarys that are being used with the -p flag.

username@localhost [~]# ldconfig -p
907 libs found in cache `/etc/' (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6, hwcap: 0x0001000000000000) => /opt/blackdown-jdk- (libc6) => /lib/ (libc6) => /lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/

If you want to make make the changes more permanent, so that you don't have to remember to specify the directory next time you run the command, you can add it to the /etc/ file, though different linux distributions manage this file in different ways.

Last modified: 23/02/2007 Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top