error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file

1. Errors reported when running individual tools and cause analysis

  When the author runs a tool in the Linux environment, the following error is reported.

error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

  Error message: error while loading shared library: libevent-1.4.so.2: cannot open shared object file: libevent-1.4.so.2 is not installed on this machine or does not exist in the library file path.

  You can use the following command to check whether libevent-1.4.so.2 is installed on the machine.

[root@vm]# ls -al /usr/lib | grep libevent
[root@vm]# ls -al /usr/lib64 | grep libevent

  The above command did not find the corresponding library file, so when running a tool that depends on this class library, the above error is reported. The solution is to install libevent.

Two, libevent installation steps
2.1 Download the installation package

  Download the libevent installation package, official website address: https://libevent.org/ .

  This article downloads the libevent-1.4.14b-stable.tar.gz version, you can directly open the https://github.com/downloads/libevent/libevent/libevent/libevent-1.4.14b-stable.tar.gz link in the browser to download , or in a Linux environment wget https://github.com/downloads/libevent/libevent/libevent-1.4.14b-stable.tar.gz.

2.2 Decompression

  Upload the installation package to the Linux server and decompress it.

[root@vm]# tar -zxvf libevent-1.4.14b-stable.tar.gz
2.3 Configuration, compilation, installation

  Switch to the main directory of libevent after decompression, configure the installation path, and then compile and install. The steps are as follows.

[root@vm]# cd libevent-1.4.14b-stable/

[root@vm]# ./configure --prefix=/usr

[root@vm]# make

[root@vm]# make install
2.4 Create a soft link

  libevent will be installed under /usr/lib or /usr/local/lib, this time it is installed under the path of /usr/lib. Some soft links can be created so that other programs can find the libevent library when running, such as creating soft links under /usr/lib64.

[root@vm]# ln -s /usr/lib/libevent-1.4.so.2.2.0 /usr/lib64/libevent-1.4.so.2
2.5 Check whether the installation is successful

  You can check whether there are libevent libraries under different class library paths to check whether the installation is successful, as shown below.

[root@vm]# ls -al /usr/lib |grep libevent
lrwxrwxrwx   1 root root     21 May 10 15:46 libevent-1.4.so.2 -> libevent-1.4.so.2.2.0
-rwxr-xr-x   1 root root 442592 May 10 15:46 libevent-1.4.so.2.2.0
lrwxrwxrwx   1 root root     21 May 10 15:46 libevent-2.0.so.5 -> libevent-2.0.so.5.1.9
lrwxrwxrwx   1 root root     32 May 10 10:53 libevent-2.0.so.5.1.9 -> /usr/lib64/libevent-2.0.so.5.1.9
-rw-r--r--   1 root root 806914 May 10 15:46 libevent.a
lrwxrwxrwx   1 root root     26 May 10 15:46 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.2.0
-rwxr-xr-x   1 root root 165584 May 10 15:46 libevent_core-1.4.so.2.2.0
-rw-r--r--   1 root root 270444 May 10 15:46 libevent_core.a
-rwxr-xr-x   1 root root    988 May 10 15:46 libevent_core.la
lrwxrwxrwx   1 root root     26 May 10 15:46 libevent_core.so -> libevent_core-1.4.so.2.2.0
lrwxrwxrwx   1 root root     27 May 10 15:46 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.2.0
-rwxr-xr-x   1 root root 345816 May 10 15:46 libevent_extra-1.4.so.2.2.0
-rw-r--r--   1 root root 644708 May 10 15:46 libevent_extra.a
-rwxr-xr-x   1 root root    995 May 10 15:46 libevent_extra.la
lrwxrwxrwx   1 root root     27 May 10 15:46 libevent_extra.so -> libevent_extra-1.4.so.2.2.0
-rwxr-xr-x   1 root root    953 May 10 15:46 libevent.la
lrwxrwxrwx   1 root root     21 May 10 15:46 libevent.so -> libevent-1.4.so.2.2.0
[root@vm]# 
[root@vm]# ls -al /usr/lib64 |grep libevent
lrwxrwxrwx   1 root root       30 May 10 16:03 libevent-1.4.so.2 -> /usr/lib/libevent-1.4.so.2.2.0
lrwxrwxrwx   1 root root       21 Jun 25  2019 libevent-2.0.so.5 -> libevent-2.0.so.5.1.9
-rwxr-xr-x   1 root root   297792 Jun 14  2014 libevent-2.0.so.5.1.9
lrwxrwxrwx   1 root root       26 Jun 25  2019 libevent_core-2.0.so.5 -> libevent_core-2.0.so.5.1.9
-rwxr-xr-x   1 root root   179800 Jun 14  2014 libevent_core-2.0.so.5.1.9
lrwxrwxrwx   1 root root       27 Jun 25  2019 libevent_extra-2.0.so.5 -> libevent_extra-2.0.so.5.1.9
-rwxr-xr-x   1 root root   133864 Jun 14  2014 libevent_extra-2.0.so.5.1.9
lrwxrwxrwx   1 root root       29 Jun 25  2019 libevent_openssl-2.0.so.5 -> libevent_openssl-2.0.so.5.1.9
-rwxr-xr-x   1 root root    24456 Jun 14  2014 libevent_openssl-2.0.so.5.1.9
lrwxrwxrwx   1 root root       30 Jun 25  2019 libevent_pthreads-2.0.so.5 -> libevent_pthreads-2.0.so.5.1.9
-rwxr-xr-x   1 root root    11200 Jun 14  2014 libevent_pthreads-2.0.so.5.1.9
[root@vm]# 

  You can see that libevent-1.4.so.2 already exists in both paths.

  Try to run the tool class that started to report an error again. At this time, it runs successfully and no error is reported.

Article reference:

Guess you like

Origin blog.csdn.net/piaoranyuji/article/details/130604262