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下面,发现一个网站基本 ...
随机推荐
- iscroll4 捕捉元素开发手机焦点图滑动效果
html标准代码格式 <div id="wrapper"> <div id="scroller" > <ul id="t ...
- [转]linux sort,uniq,cut,wc命令详解
sort sort 命令对 File 参数指定的文件中的行排序,并将结果写到标准输出.如果 File 参数指定多个文件,那么 sort 命令将这些文件连接起来,并当作一个文件进行排序. sort语法 ...
- C语言atan2()函数:求y/x的反正切值
头文件:#include <math.h> atan2() 函数用于求 y / x 的反正切值.其原型为: double atan2(double y, double x); [参数 ...
- ebs如何将客户化的PL/SQL程序发布到webservice
as:cux_gl_hec_iface_soa_pkg. 1.将package声明部分的内容拷贝出来另存为cux_gl_hec_iface_soa_pkg.pls的文件: 2.将该文件上传到服务器上拥 ...
- 创建DAO模式的步骤
1.建立数据库epet 2.创建实体类,和相对应的数据库是对应的 3.创建Dao的基类接口类BaseDao 4.创建Dao的实现类BaseDaoImpl 5.创建具体表的Dao类 6.创建具体表的Da ...
- setFeatureInt、android 自定义标题栏
Android 自带的toolbar 往往不能很好的的满足我们的个性化要求.因此我们经常使用自定的的标题栏.而Android系统本身也允许我们自定以标题栏. 记录一下,自定义标题栏常遇到的问题.先上效 ...
- IE8 jq focus BUG
jq的 .focus() 在IE8下面会有一些意想不到的BUG,下面是解决办法: 一.我做的项目中有些场景需要用到键盘的回车作为触发事件,然后把focus移到其他功能或者按钮上面,刚刚好这个按钮或者功 ...
- JuqeryResize
//添加 (function ($, h, c) { var a = $([]), e = $.resize = $.extend($.resize, {}), i, k = "setTim ...
- js call 以及apply
用实例来讲:一半什么场合用到bind.call.apply呢? [一个对象 A]的方法被[另一个对象 B][引用]的时候(请注意 引用 的意思,区分调用 ):[对象A]的方法内的this作用域就不指向 ...
- python学习(解析python官网会议安排)
在学习python的过程中,做练习,解析https://www.python.org/events/python-events/ HTML文件,输出Python官网发布的会议时间.名称和地点. 对ht ...