报错libtest: error while loading shared libraries: libuv.so.1: cannot open shared object file: No such file or directory
使用g++编译、运行libuv的demo错误解决
我们通过例子来讲述监视器的使用. 例子中空转监视器回调函数被不断地重复调用, 通过例子我们也可以了解到:
由于设置了监视器, 所以调用 uv_run() 是程序会阻塞, 空转监视器将会在计数器达到设定的值时停止(监视), uv_run() 会退出因为此时程序中没有活动的监视器了.
测试代码如下
#include <stdio.h>
#include <uv.h> int64_t counter = ; static void wait_for_a_while(uv_idle_t* handle) {
counter++; if (counter >= 10e6)
uv_idle_stop(handle);
} int main() {
uv_idle_t idler;
uv_idle_init(uv_default_loop(), &idler);
uv_idle_start(&idler, wait_for_a_while); printf("Idling...\n");
uv_run(uv_default_loop(), UV_RUN_DEFAULT); return ;
}
g++ -c libuv_test.c //生成libuv_test.o文件
g++ -o libuvtest libuv_test.o /usr/local/bin/libuv.so 生成目标文件要包含libuv.so库,这里需要全路径,因为我们用到了它里面的函数。
chmod 755 libtest //赋予执行权限
./libtest
报错libtest: error while loading shared libraries: libuv.so.1: cannot open shared object file: No such file or directory
分析原因:ld提示找不到库文件,而库文件就在/usr/local/lib目录中。
链接器ld默认的目录是/lib和/usr/lib,如果放在其他路径也可以,需要让ld知道库文件在哪里。
方法1:
编辑/etc/ld.so.conf文件,在新的一行中加入库文件所在目录;
运行ldconfig,以更新/etc/ld.so.cache文件;
方法2:
在/etc/ld.so.conf.d/目录下新建任何以.conf为后缀的文件,在该文件中加入库文件所在的目录;
运行ldconfig,以更新/etc/ld.so.cache文件;
我的解决办法是:在./etc/ld.so.conf文件中添加了/usr/local/lib/
本人觉得第二种办法更为方便,对于原系统的改动最小。因为/etc/ld.so.conf文件的内容是include /etc/ld.so.conf.d/*.conf
所以,在/etc/ld.so.conf.d/目录下加入的任何以.conf为后缀的文件都能被识别到。
ld.so.cache的更新是递增式的,就像PATH系统环境变量一样,不是从头重新建立,而是向上累加。
除非重新开机,才是从零开始建立ld.so.cache文件。
报错libtest: error while loading shared libraries: libuv.so.1: cannot open shared object file: No such file or directory的更多相关文章
- 运行 puppeteer 报错 chrome: error while loading shared libraries: libpangocairo-1.0.so.0: cannot open shared object file: No such file or directory
运行 puppeteer 报错 chrome: error while loading shared libraries: libpangocairo-1.0.so.0: cannot open sh ...
- linux下报错:error while loading shared libraries
linux执行bin程序报: error while loading shared libraries:libncurses.so.5: cannot open shared object file: ...
- 解决ffmpeg执行报错“ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory”的问题
问题现象: 执行ffmpeg命令后报错: ffmpeg: error : cannot open shared object file: No such file or directory 出问题的环 ...
- java 罕见的依赖报错 jstat: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
java 都用了N长时间了,突然,意外地发现有一个依赖的so文件从来没找见过 # ldd /usr/bin/java linux-vdso.so.1 => (0x00007fffba76900 ...
- imod报错:error while loading shared libraries: libjpeg.so.62的解决办法
the file libjpeg.so.62(in /usr/lib/libjpeg.so.62)belongs to the package libjpeg62so try to reinstall ...
- nginx排错error while loading shared libraries:libpcre.so.1:cannot open shared object file:No such file or directory
启动nginx报错:error while loading shared libraries:libpcre.so.1:cannot open shared object file:No such f ...
- 使用arm-none-eabi-gdb报错error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
使用arm-none-eabi-gdb报错error while loading shared libraries: libncurses.so.5: cannot open shared objec ...
- 报错:/application/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
启动zabbix_server时报错: /application/zabbix/sbin/zabbix_server: error while loading shared libraries: li ...
- nginx检查报错 error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory
在centos7.3上编译安装nginx-1.12.2 启动测试出错 [root@web02 local]# /usr/local/nginx/sbin/nginx -t /usr/local/ngi ...
随机推荐
- OpenSUSE 服务器系统部署
1.准备 1.1 下载系统 下载地址:https://software.opensuse.org/distributions/leap 目前的最新版本为leap,推荐使用种子下载速度较快. 1.2 配 ...
- Android性能优化-减小APK大小
前言 用户通常会避免下载比较大的应用,特别是连接到2G和3G网络,或者按流量收费的设备.这篇文章描述了如何减小apk的大小,帮助你让更多的用户下载你的app. 一 理解APK的结构 在讨论如何减小ap ...
- linux 使用ifstat查看网络使用情况
首先安装ifstat wget http://distfiles.macports.org/ifstat/ifstat-1.1.tar.gz tar xzvf ifstat-1.1.tar.gz cd ...
- 解决 Docker pull 出现的net/http: TLS handshake timeout 的一个办法
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=http://f2d6cb40.m.daocloud.io\"&q ...
- 在Razor中输出Html的两种方式
Razor中所有的Html都会自动编码,这样就不需要我们手动去编码了(安全),但在需要输出Html时就是已经转义过的Html文本了,如下所示: @{ string thisTest = "& ...
- 全球最全路由DNS服务器IP地址
全球只有13台路由DNS根服务器,在13台路由服务器中,名字分别为“A”至“M”,其中10台设置在美国,另外各有一台设置于英国.瑞典和日本.下表是这些机器的管理单位.设置地点及最新的IP地址. 供应商 ...
- ubuntu下解压文件命令大全(转)
ubuntu 下rar解压工具安装方法: 压缩功能 安装 sudo apt-get install rar卸载 sudo apt-get remove rar 解压功能 安装 sudo apt-get ...
- 从public void onPreviewFrame(byte[] data, Camera arg1)拿到Bitmap(收集)
private PreviewCallback pc = new PreviewCallback(){ public void onPreviewFrame(byte[] data, Camera a ...
- Swift 静态派发和动态派发
前言 方法是 Swift 中的一个重要概念,方法允许你把需要复用的代码封装进方法中,这样当你调用方法时,实际上你的想法是执行方法中的那些代码,方法的出现极大的提高了方法的复用性. Swift 工程的环 ...
- 透彻理解Spring事务设计思想之手写实现
前言 事务,是描述一组操作的抽象,比如对数据库的一组操作,要么全部成功,要么全部失败.事务具有4个特性:Atomicity(原子性),Consistency(一致性),Isolation(隔离性),D ...