Error while loading shared libraries: XXX. So. X "error cause and Solution

Source: Internet
Author: User

Generally, when executing some external programs in Linux, we may prompt that the shared library cannot be found, for example:

 

Tmux: Error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: no such file or directory


There are two common causes. One is that the operating system does not contain the Shared Library (lib *. so. * file) or the version of the shared library is incorrect. In this case, download and install it online.

Another reason is that the shared library has been installed, but when you execute the program that needs to call the shared library, the program cannot find the shared library file according to the default shared library path.

After installing the shared library, pay attention to the following issues:

1) if the shared library file is installed in the/lib or/usr/lib directory, run the ldconfig command.

The ldconfig command is mainly used in the default search directory (/lib and/usr/lib) and dynamic library configuration file/etc/lD. so. search for the shared dynamic link library (Format: lib *. so *) to create a dynamic loader (LD. so) the required connection and cache file. the default cached file is/etc/lD. so. cache. This file stores the list of Dynamic Linked Library names in the sorted order.

2) If the shared library file is installed in/usr/local/lib (many open-source shared libraries are installed in this directory) or other "non-/lib or/usr/lib" directories, add the new Shared Library directory to the shared library configuration file/etc/LD before executing the ldconfig command. so. conf, as follows:

# Cat/etc/lD. So. conf
Include lD. So. conf. d/*. conf
# Echo "/usr/local/lib">/etc/lD. So. conf
# Ldconfig

3) if the shared library file is installed in another "non-/lib or/usr/lib" directory, but does not want to be in/etc/lD. so. add path in conf (or do not have permission to add path ). you can export a global variable LD_LIBRARY_PATH, and then find the shared library in the directory when running the program.

LD_LIBRARY_PATH indicates the directories in which the loader can find the shared library. you can set multiple search directories separated by colons. for example, if you have installed a MySQL file to the/usr/local/MySQL directory, a large number of library files are under/usr/local/MySQL/lib. bashrc or. add the following statement to bash_profile or shell:

Export LD_LIBRARY_PATH =/usr/local/MySQL/lib: $ LD_LIBRARY_PATH

Generally, this is only a temporary solution, which is used when you do not have the permission or need it temporarily.

4) if the library file required by the program is lower than the existing village file version in the system, you can make a link
For example:
Error while loading shared libraries: libncurses. so.4: cannot open shared
Object File: no such file or directory

Ls/usr/lib/libncu *
/Usr/lib/libncurses. A/usr/lib/libncurses. so.5
/Usr/lib/libncurses. So/usr/lib/libncurses. so.5.3

Although libncurses. so.4 is not available, libncurses. so.5 is backward compatible.
Just create a link.
Ln-S/usr/lib/libncurses. so.5.3/usr/lib/libncurses. so.4

Source: http://blog.csdn.net/sahusoft/article/details/7388617
Http://www.vrlinux.com/shujukuyingyong/20100407/26958.html

Error while loading shared libraries: XXX. So. X "error cause and Solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.