iangilham.com

By on

software linux

Sometimes when you try to launch an application on Linux, typically one you have built yourself, you might get an error like this:

./myapp: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

When this happens, it is up to you to figure out what the problem is. Fortunately, you have a tool called ldd to help.

# using which to get the full path to the executable
ldd $(which sh)
    linux-vdso.so.1 => (0x00007fff44fff000)
    libtinfo.so.5 => /lib64/libtinfo.so.5
    ...

If any of the shared (dynamic) libraries are not found, you will have to locate them and add them to your LD_LIBRARY_PATH environment variable. something like the following should do the trick:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/missing/library