首先运行编译 sample 中的 hello.c,命令如下: -levent 表示 动态链接库
生成 hello 可执行文件,运行 ./hello ,出现如下错误:
./hello: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
原因是:系统不知道 libevent-2.0.so. 放在哪个目录下,这个时候就要在 /etc/ld.so.conf 中加入 libevent-2.0.so 所在的目录。
首先,先找到 /etc/ld.so.conf
然后 将路径添加进去:
最后,更新配置,输入 ldconfig。
此时会出现 “/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied” 权限受限,
改成 sudo ldconfig 即可。