Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For this question I'll be using a specific example, but really this generalizes to pretty much any binary on linux that can't seem to find its' dependent libraries. So, I have a program that won't run because of missing libraries:

./cart5: error while loading shared libraries: cannot open shared object file: No such file or directory

ldd sheds some light on the issue: =>  (0x00007fff18b01000) => not found => /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/ (0x00007f0975830000) => /lib/ (0x00007f09755af000) => /lib/ (0x00007f0975399000) => /lib/ (0x00007f0975040000) => /lib/ (0x00007f0974e2b000)
/lib64/ (0x00007f0975b36000)

However, corona is installed:

oliver@human$ find / -name 2> /dev/null


How do I tell the binary where to look for the "missing" library?

share|improve this question
up vote 15 down vote accepted

For a once-off, set the variable LD_LIBRARY_PATH to a colon-separated list of directories to search. This is analogous to PATH for executables, except that the standard system directories are additionally searched after the ones specified through the environment.

LD_LIBRARY_PATH=/usr/local/lib64 ./cart5

If you have a program that keeps libraries in a non-standard location and isn't able to find them on its own, you can write a wrapper script:

if [ -n "$LD_LIBRARY_PATH" ]; then
exec /path/to/cart5 "$@"

The list of standard system directories is kept in /etc/ Recent systems allow this file to include other files; if yours contains something like include /etc/*.conf, create a new file called /etc/ containing the directories you want to add. After you change /etc/ or an included file, run /sbin/ldconfig for your changes to take effect (this updates a cache).

(LD_LIBRARY_PATH also applies to many other unices, including FreeBSD, NetBSD, OpenBSD, Solaris and Tru64. HP-UX has SHLIB_PATH and Mac OS X has DYLD_LIBRARY_PATH. /etc/ has analogs on most unices but the location and syntax differs more widely.)

share|improve this answer
Fantastic, thank you very much. I had no idea about /etc/, and it will be very useful to me in the future. – Mala Sep 26 '10 at 6:26

If you want to avoid LD_LIBRARY_PATH, you can also do this, during linking:

gcc -o exename -L/path/to/dynamiclib/ -lnameofLib \
    -Wl,-R/path/to/dynamiclib/ sourceCode1.c ...

The -Wl,... is used to pass extra commands to the linker, and in this case, with -R you tell the linker to store this path as the "default search path" for the .so.

I keep notes of many small tips like this one, at my site:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.