Ubuntu 查询 so 归属的 package
.
.
.
.
.
今天 LZ 在运行一个程序的时候,出现找不到 so 库的情况:
>$ ./core
./core: error while loading shared libraries: libudev.so.: cannot open shared object file: No such file or directory
>$
可以看出来, core 这个程序依赖了一个叫做 libudev.so 的库,但是再系统中找不到这个库,那么就需要安装一下。
可是如果通过 apt-get 的方式安装的话,需要知道 libudev.so 在哪个软件包中才行。
那么问题来了,怎样查找一个 so 库在哪个软件包中呢?
通过 apt-file 命令就可以查找了。
首先 apt-file 命令不像 apt-get 命令一样,它在系统中是没有预装的,需要我们手动安装一下:
>$ sudo apt-get install apt-file
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
curl libconfig-file-perl libregexp-assemble-perl
The following NEW packages will be installed:
apt-file curl libconfig-file-perl libregexp-assemble-perl
upgraded, newly installed, to remove and not upgraded.
Need to get kB of archives.
After this operation, kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get: http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main curl amd64 7.35.0-1ubuntu2.6 [123 kB]
Get: http://cn.archive.ubuntu.com/ubuntu/ trusty/universe libconfig-file-perl all 1.50-2 [10.1 kB]
Get: http://cn.archive.ubuntu.com/ubuntu/ trusty/universe libregexp-assemble-perl all 0.35-8 [81.2 kB]
Get: http://cn.archive.ubuntu.com/ubuntu/ trusty/universe apt-file all 2.5.2ubuntu1 [27.1 kB]
Fetched kB in 10s (22.2 kB/s)
Selecting previously unselected package curl.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../curl_7.35.0-1ubuntu2.6_amd64.deb ...
Unpacking curl (7.35.-1ubuntu2.) ...
Selecting previously unselected package libconfig-file-perl.
Preparing to unpack .../libconfig-file-perl_1.-2_all.deb ...
Unpacking libconfig-file-perl (1.50-) ...
Selecting previously unselected package libregexp-assemble-perl.
Preparing to unpack .../libregexp-assemble-perl_0.-8_all.deb ...
Unpacking libregexp-assemble-perl (0.35-) ...
Selecting previously unselected package apt-file.
Preparing to unpack .../apt-file_2..2ubuntu1_all.deb ...
Unpacking apt-file (2.5.2ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up curl (7.35.-1ubuntu2.) ...
Setting up libconfig-file-perl (1.50-) ...
Setting up libregexp-assemble-perl (0.35-) ...
Setting up apt-file (2.5.2ubuntu1) ...
The system-wide cache is empty. You may want to run 'apt-file update'
as root to update the cache. You can also run 'apt-file update' as
normal user to use a cache in the user's home directory.
>$
安装好 apt-file 工具之后还不能马上进行查找,得先更新它的索引文件才行。
从上面的提示可以看出来,更新索引文件必须使用 root 身份,所以别忘了用 sudo 命令。
>$ sudo apt-file update
Downloading complete file http://cn.archive.ubuntu.com/ubuntu/dists/trusty/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
28.0M 28.0M :: :: --:--:--
Downloading complete file http://cn.archive.ubuntu.com/ubuntu/dists/trusty-updates/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
25.5M 25.5M :: :: --:--:--
Downloading Index http://cn.archive.ubuntu.com/ubuntu/dists/trusty/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://cn.archive.ubuntu.com/ubuntu/dists/trusty/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
28.0M --:--:-- --:--:-- --:--:--
File is up-to-date.
Downloading Index http://cn.archive.ubuntu.com/ubuntu/dists/trusty-updates/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://cn.archive.ubuntu.com/ubuntu/dists/trusty-updates/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
25.5M --:--:-- --:--:-- --:--:--
File is up-to-date.
Downloading Index http://cn.archive.ubuntu.com/ubuntu/dists/trusty/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://cn.archive.ubuntu.com/ubuntu/dists/trusty/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
28.0M --:--:-- --:--:-- --:--:--
File is up-to-date.
Downloading Index http://cn.archive.ubuntu.com/ubuntu/dists/trusty-updates/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://cn.archive.ubuntu.com/ubuntu/dists/trusty-updates/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
25.5M --:--:-- :: --:--:--
File is up-to-date.
Downloading complete file http://cn.archive.ubuntu.com/ubuntu/dists/trusty-backports/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
285k 285k :: :: --:--:--
Downloading complete file http://security.ubuntu.com/ubuntu/dists/trusty-security/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
22.6M 22.6M :: :: --:--:-- 100k
Downloading Index http://security.ubuntu.com/ubuntu/dists/trusty-security/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://security.ubuntu.com/ubuntu/dists/trusty-security/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
--:--:-- --:--:-- --:--:--
File is up-to-date.
Downloading Index http://security.ubuntu.com/ubuntu/dists/trusty-security/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://security.ubuntu.com/ubuntu/dists/trusty-security/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
--:--:-- --:--:-- --:--:--
File is up-to-date.
Ignoring source without Contents File:
http://extras.ubuntu.com/ubuntu/dists/trusty/Contents-amd64.gz
>$
耐心等待这些包更新完,然后就可以查找我们要的库了。好在这些索引文件不是很大,用不了多久就更新完毕了。
接下来使用 apt-file 命令查找我们的 so 在哪个 package 中。
>$ sudo apt-file search libudev.so
libudev-dev: /usr/lib/x86_64-linux-gnu/libudev.so
libudev1: /lib/x86_64-linux-gnu/libudev.so.
libudev1: /lib/x86_64-linux-gnu/libudev.so.1.3.
>$
本来 LZ 搜索的是 libudev.so.0,但是没有搜索到,所以就只好把末尾的 .0 去掉来搜索更大的范围。
在搜索的结果中,左侧的是 package,右侧就是 so 的路径,所以在查到 package 后通过 apt-get 命令安装它就可以了。
>$ sudo apt-get install libudev1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libudev1 is already the newest version.
upgraded, newly installed, to remove and not upgraded.
>$
======================分割线====================
LZ 的运气总是不好,用 libudev.so.0 这个库来举栗子不够典型,因为这个库多少有些特殊,通过上面的安装结果可以看出来, libudev1 这个库并没有安装成功,因为它早已被安装好了。
既然我们运行的 ./core 程序中提示找不到 libudev.so.0,而我们的系统中只有一个 libudev.so.1,那么直接做一个符号链接就可以了。
>$ sudo ln -s /lib/x86_64-linux-gnu/libudev.so. /lib/x86_64-linux-gnu/libudev.so.
>$
在绝大多数情况下,通过 apt-file 命令根据 so 反查归属的 package,然后再通过 apt-get 命令安装这个 package 就可以了。
在少数情况下,比如 LZ 遇到的这种情况下,就需要通过一些变通的手段了。
Ubuntu 查询 so 归属的 package的更多相关文章
- 用纯真ip数据库.dat文件查询ip归属
网址:http://www.cz88.net/ 下载安装后,有这个文件: 安装路径/ip/qqwry.dat 创建实例的时候吧这个文件路径传入,即可调用. /** * 从纯真IP地址库查询ip归属 * ...
- 调用webservice查询手机号码归属地信息
Web Services是由企业发布的完成其特定商务需求的在线应用服务,其他公司或应用软件能够通过Internet来访问并使用这项在线服务.在这里我们使用soap协议往webservice发送信息,然 ...
- jquery使用淘宝接口跨域查询手机号码归属地实例
<h1>手机号码归属地查询</h1> <div class="outer"> <p>请输入手机号码</p& ...
- ubuntu查询某个库的相关情况
环境:Ubuntu 14.04 64bit 1.如:查询libjpeg库的位置 ldconfig -p |grep libjpeg 2.如:查询libjpeg库的相关名称 dpkg -l '*jpeg ...
- Ubuntu的Unable to locate package无法更新源问题解决方案
https://blog.csdn.net/long19910605/article/details/47017889/ 问题: 更新源时提示不能联网(does the network require ...
- ubuntu进行apt-get时候出现Package ssh is not available, but is referred to by another package 错误
今天在ubuntu进行ssh安装的时候,出现如下错误. Reading package lists... Done Building dependency tree... Done Package s ...
- Ubuntu:Unable to locate package ***
在Ubuntu 上使用apt-get 安装包时遇到 Unable to locate package 的信息 解决方案: 更细apt-get然后重新安装 #sudo apt-get update ...
- ubuntu查询命令行安装的软件的安装路径
which git // 查询git的安装路径
- 查找Ubuntu下包的归属
今天在制作docker时,发现我的程序有些依赖的包不太好找应该安装什么. 在centos下面,可以用命令: rpm -qf <libraryname> 在Ubuntu下面,发现一个网站基本 ...
随机推荐
- Json格式转换
验证Json格式可以进入 http://json.cn/ json简单说就是javascript中的对象和数组,所以这两种结构就是对象和数组两种结构,通过这两种结构可以表示各种复杂的结构1.对象:对象 ...
- PL/SQL使用技巧
1.如何在PL/SQL developer中查看所连接的oracle的版本答:select * from v$version;或者在pl/sql developer 里查看[Reports]——> ...
- msChart组件安装与编程
首先下载mschart.ocx文件,至于它所依赖的.net环境,网上有很多,本人下载的插件给出链接,http://www.cr173.com/soft/47300.html而它所依赖的环境可以从我的云 ...
- xmpp关于后台挂起的消息接收,后台消息推送,本地发送通知
想问下,在xmpp即时通讯的项目中,我程序如果挂起了,后台有消息过来,我这边的推送不过来,所以我的通知就会收不到消息,当我重新唤醒应用的时候,他才会接收到通知,消息就会推送过来,我在plist哪里设置 ...
- js 页面刷新方法
1.reload方法,该方法强迫浏览器刷新当前页面语法:location.reload([bForceGet])参数:bForceGet,可选参数,默认为false从客户端缓存里取当前页.true,则 ...
- C++中输入输出的重定向
重定向,就是: 把 原来的 cin 从键盘输入 改为从文件输入. 把 原来的 cout 向屏幕输出 改为输出到文件. 例如: cin>>line; 原来要从键盘拍入.现在自动到某文件读取, ...
- 使用英文版eclipse保存代码,出现some characters cannot be mapped using "Cp1251" character encoding.
some characters cannot be mapped using "Cp1251" character encoding. 解决办法:方案一: eclipse-> ...
- JAVA初学(1):值类型和引用类型的区别
JAVA值类型和引用类型的区别(转) [定义] 引用类型表示你操作的数据是同一个,也就 ...
- 第六百零七八天 how can I 坚持
昨天去跟着谈了个项目,涨了些见识吧,关注下客户关注的,多考虑些,昨天谈完就下班,陪着sy去了趟西单换电池,苹果的售后也真是挺垃圾的. 今天本来是要搭搭环境的,结果代码没搞来,明天去客户那边搞代码,感觉 ...
- 《跑跑跑》(五)——添加障碍物,Tiled障碍层的使用
[转]http://blog.csdn.net/u010778159/article/details/44036365 首先利用TiledMap在原来的地图上添加上障碍物,先新建两个图层,分别叫bar ...