报错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 ...
随机推荐
- Voltage Translation for Analog to Digital Interface ADC
Voltage Translation for Analog to Digital Interface 孕龙逻辑分析仪 ZeroPlus Logic Analyzer How to modify an ...
- Android:TextView控件
3.2.1 TextView TextView 可以说是 Android 中最简单的一个控件了,你在前面其实也已经和它打过了一 些打交道.它主要用于在界面上显示一段文本信息,比如你在第一章看到的 ...
- Linux 操作 oracle 数据库
1.Oracle监听启动命令:lsnrctl start 2. sqlplus 登录数据库 3.OS版本及Oracle版本 select banner from v$version; 4.查询该数 ...
- SharePoint 2019 离线安装准备工具
前言 最近需要安装SharePoint 2019,然而,服务器并没有网络,所以需要离线安装. 离线安装的步骤很简单,就是把所以得准备工具下载下来,然后修改好命令,使用命令安装即可. 准备工具下载路径 ...
- 你的项目真的需要Session吗? redis保存session性能怎么样?
在web开发中,Session这个东西一直都很重要,至少伴随我10年之久, 前一段时间发生一个性能问题,因为Redis session 问题,后来想想 其实我的项目session 是不需要的. 先看看 ...
- Linux 10字符串命令病毒的处理记录
刚上线的测试服务器不停的向外发包,且CPU持续100%,远程登录后查看发现有一长度为10的随机字符串进程,kill掉,会重新生成另外长度为10的字符串进程.删除文件也会重复生成,非常痛苦.查阅cron ...
- Windows平台下tomcat 性能调优
Tomcat 线程查看工具: https://blog.csdn.net/jrainbow/article/details/49026365 16G内存 Tomcat并发优化.内存配置.垃圾回收.宕机 ...
- 在Centos6或者7上安装Kafka最新版
一.官网 http://kafka.apache.org/downloads.html 二.Kafka简介 Kafka是由Apache软件基金会开发的一个开源流处理平台,由Scala和Java编写.K ...
- hustoj升级
sudo su svn up hustoj-read-only cd hustoj-read-only cd core sudo ./make.sh 有冲突 全部回答r http://www.hu ...
- CentOS下防御或减轻DDoS攻击方法(转)
查看攻击IP 首先使用以下代码,找出攻击者IP netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n 将会得 ...