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下面,发现一个网站基本 ...
随机推荐
- 定位form光标行
In AX2009 if you call the research() method on a form passing true, the cursor position within a gri ...
- Github-素材篇
my github: http://github.com/yaochao
- dubbo入门示例
前提准备: 在本次实验之前,需要准备一下几个包: Spring中的aop.beans.context.core.expression以及struts中的commons-logging.javassis ...
- 在线编辑器的使用总结(kindeditor , )
1).kindedtor中让编辑框默认为“HTML代码/源代码”模式 [javascript] view plaincopyprint? <script> // 自定义插件 #1 Kind ...
- .this语句指的是什么
This通常指的是当前对象的引用
- slickedit的alias配置
使用slickedit很喜欢它的多语言支持,可以快速查看变量的定义和结构.我一般写verilog较多,使用emcas很方便,但是感觉查看代码结构不太方便(也可能是我不会设置).所以希望能够在slick ...
- 来自 Thoughtram 的 Angular 2 系列资料
Angular 2 已经正式 Release 了,Thoughtram 已经发布了一系列的文档,对 Angular 2 的各个方面进行深入的阐释和说明. 我计划逐渐将这个系列翻译出来,以便对大家学习 ...
- Java Docs
1 Java Docs on Oracle: 1.1 Online(EN): JavaSE6 http://docs.oracle.com/javase/6/docs/api/index.htm ...
- 可分组的选择框控件(MVVM下)(Toggle样式 仿造单选框RadioButton,复选框CheckBox功能)
原地址: http://www.cnblogs.com/yk250/p/5660340.html 效果图如下:支持分组的单选框,复选框样式和MVVM下功能的实现.这是项目中一个快捷键功能的扩展. 1, ...
- 慕课网-Java入门第一季-7-4 编程练习
来源:http://www.imooc.com/code/1634 小伙伴们,请根据所学知识,参考注释,在代码编辑器中将代码补充完整.编写一个 Java 程序,实现输出学生年龄的最大值 要求: 1. ...