Archive for October, 2007

Shared Libraries Used by and Executable

Saturday, October 13th, 2007

A common problem for people is running an executable and having it fail because it cannot find some shared library need for the executable. The best way to make sure that an executable has access to all the shared libraries it needs is the ldd command. Just run it:

terry@c103:~$ ldd /bin/bash
linux-gate.so.1 => (0xffffe000)
libncurses.so.5 => /lib/libncurses.so.5 (0xb7f07000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7f03000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7dc1000)
/lib/ld-linux.so.2 (0xb7f59000)
terry@c103:~$

If any of the libraries are not found, they will show up as missing. Use the LD_LIBRARY_PATH environment variable to add in the path to the missing libraries.
terry@c103:~$ export LD_LIBRARY_PATH=~/lib
terry@c103:~$ env | grep LD
LD_LIBRARY_PATH=/home/terry/lib
terry@c103:~$