安装了libevent和memcached之后却发现在执行的时候出现了 error while loading shared libraries问题

今天晚上心血来潮装libevent和memcached,可是却出现了奇葩的问题,结果一看越来是引导文件的路径不对!

我遇到  error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory 这样的问题是在安装memcached的时候遇到的。

我按别人的攻略安装了libevent和memcached之后却发现在执行的时候出现了。 error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory 这个错误提示。

解决类似问题的步骤我相信我的做法可以通用。

1. 首先 find / -name libevent-1.4.so.2 找到缺少的链接文件到底在那儿。

2. LD_DEBUG=libs /usr/local/bin/memcached -v

3. 从Debug信息中就知道程序去哪里找链接库了。我这边程序去 trying file=/usr/lib/libevent-1.4.so.2 而我的链接库的实际存储位置是 /usr/local/lib/libevent-1.4.so.2

4. 做一个软连接 ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2

5. 搞定。

 

这种情况特别是在软件是32位,而系统是64位的情况下出现,查了一下,软件把文件放到usr/lib下,而系统查找路径是usr/lib64下。

原文地址:https://www.cnblogs.com/dashafa/p/4010286.html