This article is from the Frequently Asked Questions for Linux, the Free/Open Source UNIX-like operating system kernel that runs on many modern computer systems. Maintained by David C. Merrill with numerous contributions by others. (v1.0).
programname: error in loading shared libraries: lib xxx..so. x: cannotopen shared object file: No such file or directory.
A: A message like this, when the program that you're trying to run uses shared libraries, usually means one of two things: the program was either compiled on a machine that had a different set of libraries or library paths than yours; or you've upgraded your libraries but not the program.
Executable programs that are linked with dynamic libraries, expect the full pathname of each of the library files it requires. So do the shared libraries, if they rely on other libraries. This is so the shared object dependencies remain as unambiguous as possible, and also as a security measure.
Short of recompiling the executable file for the libraries on the systemprobably the most desirable alternative in the long run - you can try to determine which libraries the executable file needs with the command: ldd programname. The output will be a list of the shared libraries on the system that the program needs to run, as well as the missing libraries. You can then add the library packages, or if the libraries already exist in a different directory, you can create a symbolic link so the program can find it. For example, if the program requires /usr/lib/libncurses.so.2, and your machine has /lib/libncurses.so.2, you can create a link where the program expects to find the library; e.g.:
# cd /usr/lib && ln -s /lib/libncurses.so.2 .
You should note, however, that creating library links like these should be considered a security risk, and the additional links you create will not be compatible with future upgrades. It's simply a quick fix for backward compatibility.
Also, it may take some guesswork to determine in exactly which of the system library directories the program expects to find a shared library file, because ldd will not list the paths of libraries it can't find. A program most likely will tell the run-time linker, /lib/ld.so, to look for shared libraries in /lib, /usr/lib, /usr/local/lib, or /usr/X11R6/lib, if it's an X client. But that doesn't mean that libraries can't be installed elsewhere. It helps to have some idea of the original library configuration before proceeding.
Also be sure to run ldconfig after creating the symbolic link, so that ld.so has an updated view of the system's libraries. You should also make certain that all of the library directories are listed in /etc/ld.so.conf, and perhaps in the LD_LIBRARY_PATH environment variable.