报错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 ...
随机推荐
- springboot中velocity tool中注入bean
在使用springboo的时候,遇到一个问题,想在tool类中注入一个bean,一直失败,翻了下源码,是因为工具类的初始化方法为反射class调用newInstance方法,详见 http://www ...
- JDBC(5)—DatabaseMetaData
1.简介: 使用元数据已实现通用的查询方法.元数据介绍:使用jdbc获得连接之后,得到一个Connection对象,可以通过这个对象获得DataBaseMetaData对象,该对象可以获得有关数据库管 ...
- Mysql启动失败
错误提示: 服务名无效 错误原因: mysql服务没有安装. 解决方法: 管理员的权限运行cmd 用dos命令进入到mysql安装目录下再进入到bin目录下 运行mysqld -install命令
- B - 可能的路径(gcd变形)
https://vjudge.net/contest/218366#problem/B 要不是在数学题专题里,我估计就盲目搜索了.10^18范围1s应该过不去. 再细看能感觉到是gcd的变形,但是具体 ...
- 计算请假天数JavaScript方法
前言 最近,有这么个需求,给用户做个请假审批系统,要输入请假开始时间和结束时间,同时计算出请假天数,如果年假数量不够提示不能提交,如果年假数量够的话,就走审批工作流,审批通过以后,自动在年假上减去这个 ...
- 谈一下Docker与Kubernetes集群的日志和日志管理
本文的测试环境为CentOS 7.3,Kubernetes集群为1.11.2,安装步骤参见kubeadm安装kubernetes V1.11.1 集群 日志对于我们管理Kubernetes集群及其上的 ...
- ASP.NET Core中使用Razor视图引擎渲染视图为字符串(转)
一.视图渲染说明 在有些项目需求上或许需要根据模板生产静态页面,那么你一样可以用Razor语法去直接解析你的页面从而把解析的页面生成静态页,这样的使用场景很多,不限于生成静态页面,视图引擎为我们提供了 ...
- ASP.NET Core -中间件(Middleware)使用
ASP.NET Core开发,开发并使用中间件(Middleware). 中间件是被组装成一个应用程序管道来处理请求和响应的软件组件. 每个组件选择是否传递给管道中的下一个组件的请求,并能之前和下一组 ...
- Markdown 语法手册 - 完整版(下)
6. 引用 语法说明: 引用需要在被引用的文本前加上>符号. 代码: > 这是一个有两段文字的引用, > 无意义的占行文字1. > 无意义的占行文字2. > > 无 ...
- 服务 Service 简单案例 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...