项目场景1:
安装libevent库
问题描述1
执行./configure 时出现以下错误
configure: error: openssl is a must but can not be found. You should add the directory containing
openssl.pc' to the
PKG_CONFIG_PATH’ environment variable, or setCFLAGS' and
LDFLAGS’ directly for openssl, or use `–disable-openssl’ to disable support for openssl encryption
执行make出现以下错误
make: *** No targets specified and no makefile found. Stop.
原因分析1:
缺少openssl
解决方案1:
sudo apt install libssl-dev
项目场景2:
运行用到libevent库的程序
问题描述2
编译hello-world.c,运行hello时,出现如下错误。
./hello: error while loading shared libraries: libevent-2.1.so.7: cannot open shared object file: No such file or directory
原因分析2:
在运行时,程序无法找到libevent-2.1.so.7这个动态库,因为该动态库在默认安装时,存放的路径在/usr/local/lib下,不在系统的默认查找路径内。
解决方案2:
将/usr/local/lib路径添加到/etc/ld.so.conf配置文件中
sudo vi /etc/ld.so.conf //需要sudo,否则出现 Can‘t open file for writing
添加路径
sudo ldconfig //更新一下,使该配置生效
也有说
起不来的运行 export LD_LIBRARY_PATH=/usr/local/lib 就可以了
可以试试