0

我在我的源代码中使用 libevent,编译程序后,我运行它,我得到以下错误:

./my_program: error while loading shared libraries: libevent-1.4.so.2: cannot open shared

以前我对如何安装 libevent 和安装类似libverto-libevent-0.2.5-1.fc16.x86_64.rpm. 无论如何,最后我编译并安装了libevent源代码./configure, make and make install,但它安装在/usr/libwhile/usr/lib64被之前的残留.so文件占用,如下:

    [esolve@kity lib]$ ls /usr/lib64|grep "libevent"
    libevent-2.0.so.5
    libevent-2.0.so.5.0.1
    libevent_core-2.0.so.5
    libevent_core-2.0.so.5.0.1
    libevent_extra-2.0.so.5
    libevent_extra-2.0.so.5.0.1
    libevent_openssl-2.0.so.5
    libevent_openssl-2.0.so.5.0.1
    libevent_pthreads-2.0.so.5
    libevent_pthreads-2.0.so.5.0.1
    libeventviews.so.4
    libeventviews.so.4.8.0

    [esolve@kity lib]$ ls /usr/lib|grep "libevent"
    libevent-1.4.so.2
    libevent-1.4.so.2.2.0
    libevent.a
    libevent_core-1.4.so.2
    libevent_core-1.4.so.2.2.0
    libevent_core.a
    libevent_core.la
    libevent_core.so
    libevent_extra-1.4.so.2
    libevent_extra-1.4.so.2.2.0
    libevent_extra.a
    libevent_extra.la
    libevent_extra.so
    libevent.la
    libevent.so
    [esolve@kity lib]$

我该怎么做才能成功运行 ./my_program ?我的系统是fedora 16,我要链接libevent-1.4.so 谢谢!

顺便提一句:

我试过rpm -e all previous-wrongly-installed rpm package,有一些“该包未安装”的提示,我得到了

    [esolve@kity lib]$ ls /usr/lib64|grep "libevent"
    lrwxrwxrwx    1 root root       21 Apr  3  2012 libevent-2.0.so.5 -> libevent-2.0.so.5.0.1
    -rwxr-xr-x    1 root root   280720 Feb  9  2011 libevent-2.0.so.5.0.1
    lrwxrwxrwx    1 root root       26 Apr  3  2012 libevent_core-2.0.so.5 -> libevent_core-2.0.so.5.0.1
    -rwxr-xr-x    1 root root   165760 Feb  9  2011 libevent_core-2.0.so.5.0.1
    lrwxrwxrwx    1 root root       27 Apr  3  2012 libevent_extra-2.0.so.5 -> libevent_extra-2.0.so.5.0.1
    -rwxr-xr-x    1 root root   127400 Feb  9  2011 libevent_extra-2.0.so.5.0.1
    lrwxrwxrwx    1 root root       29 Apr  3  2012 libevent_openssl-2.0.so.5 -> libevent_openssl-2.0.so.5.0.1
    -rwxr-xr-x    1 root root    21352 Feb  9  2011 libevent_openssl-2.0.so.5.0.1
    lrwxrwxrwx    1 root root       30 Apr  3  2012 libevent_pthreads-2.0.so.5 -> libevent_pthreads-2.0.so.5.0.1
    -rwxr-xr-x    1 root root     6992 Feb  9  2011 libevent_pthreads-2.0.so.5.0.1
    lrwxrwxrwx    1 root root       22 Jul 31  2012 libeventviews.so.4 -> libeventviews.so.4.8.0
    -rwxr-xr-x    1 root root   974656 Jul  9  2012 libeventviews.so.4.8.0
4

2 回答 2

2

对于从源代码安装的库,您必须运行 ldconfig,packagemanagers 会为您执行此操作。但是,如果您从源代码构建库,则必须运行

./configure
make
make install 

但是也

ldconfig

两者都make install应该ldconfig作为超级用户完成

man ldconfig

我可以告诉你更多关于缓存和更新库的信息。

于 2013-05-20T21:59:50.147 回答
0

你不能删除 libevent 2.0 吗?

您可以在 rpm 方法中使用 rpm -e。

或者,在您的 Makefile 中,您可以链接 libevent-2.0 而不是 libevent-1.4。

于 2013-06-01T09:14:59.650 回答