Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I am trying to start a program that relies on some libraries that are in my path, however, the program says it cannot find the files:

11:45:27 ~ > echo $PATH

11:45:33 ~ > brains3
/home/mri/Software/BRAINS3/bin/brains3_real: error while loading shared libraries: libiplUtils.so: cannot open shared object file: No such file or directory

11:45:35 ~ > sudo find / -name libiplUtils.so
[sudo] password for mri: 

Does anybody have an idea how to fix this?

share|improve this question
Libraries aren't looked for in $PATH - what's your OS? – Mat Feb 14 '13 at 16:58
up vote 2 down vote accepted

You can specify the library search path with the environment variable LD_LIBRARY_PATH.

$ export LD_LIBRARY_PATH=/home/mri/Software/BRAINS3/lib
$ brains3

You shouldn't set this variable for your whole system. If you can't/don't want to install the software system wide you could create a wrapper script.

share|improve this answer

The dynamic linker searches for libraries en LD_LIBRARY_PATH.

share|improve this answer

Unix systems tend to sort different types of files into different directories. There are separate directories for executables (e.g. /usr/bin), documentation (e.g. /usr/man, /usr/info, …), native libraries (e.g. /usr/lib), Perl libraries (e.g. /usr/lib/perl5), and so on. Correspondingly, there are different path variables, all with the same syntax (colon-separated list of directories): PATH for executables, MANPATH for man pages, LD_LIBRARY_PATH for native libraries¹, PERL5LIB for Perl libraries, and so on.

For native libraries, there are system default libraries that are in the search path whether mentioned in the LD_LIBRARY_PATH environment variable or not. On Linux, these directories are listed in /etc/ld.so.conf (also, /lib and /usr/lib are always in the search path).

You therefore have several possibilities:

  • Add /home/mri/Software/BRAINS3/lib to /etc/ld.so.conf (Linux-specific, other unix variants may have a similar file). Run ldconfig to make the change take effect.
  • Add export LD_LIBRARY_PATH=/home/mri/Software/BRAINS3/lib in /etc/profile (applies to all users) or in ~/.profile (applies only to you).
  • Make a wrapper script:

    export LD_LIBRARY_PATH=/home/mri/Software/BRAINS3/lib
    exec /home/mri/Software/BRAINS3/bin/brains3 "$@"
  • Create symbolic links to the libraries in /home/mri/Software/BRAINS3/lib in another directory on the search path:

    ln -s /home/mri/Software/BRAINS3/bin/brains3/lib*.so.* /usr/local/lib/

¹ LD_LIBRARY_PATH is the name on most unix variants, but Mac OS X uses DYLD_LIBRARY_PATH instead.

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.