8

我正在为程序使用 libevent,我在两台计算机 A 和 B 上编译我的程序,在 A 上执行成功,但在 BI 上出现以下错误:

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

供参考:

A和B都是fedora系统,A和B都是我下载libevent-1.4.14b-stable.tar.gz的,通过configure/make/make install安装。

在一个

    [esolve@kitty temp]$ uname -r
    3.6.10-2.fc16.x86_64
    [esolve@kitty temp]$ ls -al /usr/local/lib64 | grep libevent
    [esolve@kitty temp]$ ls -al /usr/lib64 | grep libevent
    [esolve@kitty temp]$ ls -al /usr/lib | grep libevent
    lrwxrwxrwx   1 root root       32 May 21 00:25 libevent-1.4.so.2 -> /usr/local/lib/libevent-1.4.so.2
    [esolve@kitty temp]$ ls -al /usr/local/lib | grep libevent
    lrwxrwxrwx   1 root root     21 May 21 00:22 libevent-1.4.so.2 -> libevent-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 435304 May 21 00:22 libevent-1.4.so.2.2.0
    -rw-r--r--   1 root root 793178 May 21 00:22 libevent.a
    lrwxrwxrwx   1 root root     26 May 21 00:22 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 160352 May 21 00:22 libevent_core-1.4.so.2.2.0
    -rw-r--r--   1 root root 269580 May 21 00:22 libevent_core.a
    -rwxr-xr-x   1 root root    988 May 21 00:22 libevent_core.la
    lrwxrwxrwx   1 root root     26 May 21 00:22 libevent_core.so -> libevent_core-1.4.so.2.2.0
    lrwxrwxrwx   1 root root     27 May 21 00:22 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 342122 May 21 00:22 libevent_extra-1.4.so.2.2.0
    -rw-r--r--   1 root root 631804 May 21 00:22 libevent_extra.a
    -rwxr-xr-x   1 root root    995 May 21 00:22 libevent_extra.la
    lrwxrwxrwx   1 root root     27 May 21 00:22 libevent_extra.so -> libevent_extra-1.4.so.2.2.0
    -rwxr-xr-x   1 root root    953 May 21 00:22 libevent.la
    lrwxrwxrwx   1 root root     21 May 21 00:22 libevent.so -> libevent-1.4.so.2.2.0

在 B 上:

    root@kitch server_agent]# uname -r
    3.8.5-201.fc18.x86_64
    [root@kitch server_agent]# ls -al /usr/lib | grep libevent
    lrwxrwxrwx   1 root root      32 Jun 14 17:09 libevent-1.4.so.2 -> /usr/local/lib/libevent-1.4.so.2
    [root@kitch server_agent]# ls -al /usr/local/lib | grep libevent
    lrwxrwxrwx   1 root root     21 Jun 14 16:03 libevent-1.4.so.2 -> libevent-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 435524 Jun 14 16:03 libevent-1.4.so.2.2.0
    -rw-r--r--   1 root root 805650 Jun 14 16:03 libevent.a
    lrwxrwxrwx   1 root root     26 Jun 14 16:03 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 164070 Jun 14 16:03 libevent_core-1.4.so.2.2.0
    -rw-r--r--   1 root root 270748 Jun 14 16:03 libevent_core.a
    -rwxr-xr-x   1 root root    994 Jun 14 16:03 libevent_core.la
    lrwxrwxrwx   1 root root     26 Jun 14 16:03 libevent_core.so -> libevent_core-1.4.so.2.2.0
    lrwxrwxrwx   1 root root     27 Jun 14 16:03 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 339502 Jun 14 16:03 libevent_extra-1.4.so.2.2.0
    -rw-r--r--   1 root root 642916 Jun 14 16:03 libevent_extra.a
    -rwxr-xr-x   1 root root   1001 Jun 14 16:03 libevent_extra.la
    lrwxrwxrwx   1 root root     27 Jun 14 16:03 libevent_extra.so -> libevent_extra-1.4.so.2.2.0
    -rwxr-xr-x   1 root root    959 Jun 14 16:03 libevent.la
    lrwxrwxrwx   1 root root     21 Jun 14 16:03 libevent.so -> libevent-1.4.so.2.2.0
    [root@kitch server_agent]# ls -al /usr/lib64 | grep libevent
    [root@kitch server_agent]# ls -al /usr/local/lib64 | grep libevent

为什么我的程序在 B 上出现此错误,有什么解决方案吗?谢谢!

4

1 回答 1

12

/usr/lib/libevent-1.4.so.2您的“A”系统有一个从to的符号链接,/usr/local/lib/libevent-1.4.so.2但系统“B”没有。很有可能,如果您创建它,那么一切都会开始工作。

命令应如下所示。

sudo ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2

作为替代方案,您可以通过导出为系统“B”上的临时修复程序将其添加/usr/local/lib到库路径作为测试。LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

于 2013-06-14T14:55:11.830 回答