红联Linux门户
Linux帮助

在Ubuntu14.04下编译程序出现缺失libudev.h

发布时间:2017-07-13 15:40:08来源:linux网站作者:kucoffee12
我是在编译QT程序时出现缺失libudev.h的错误提示,查看了代码,是C语言扩展是引用了libudev.h,在网上找了很久都没找到有一样的错误的,所以记录一下,以备不时之需。
 
原因:可能是libudev-dev没安装好。
 
参考“安装libudev-dev,解决依赖错误”解决了,过程有点小小的不同,但最终是安装libudev-dev,下面附上这篇文章的内容:
安装libudev-dev,解决依赖错误
//被依赖的libudev1是11.2版本
$ dpkg -l libudev1
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name   Version   Architecture   Description
ii  libudev1:amd64   198-0ubuntu11.2   amd64   libudev shared library
ii  libudev1:i386   198-0ubuntu11.2   i386   libudev shared library
//要安装libudev-dev这个包
zhangze@zhangze-OptiPlex-7010:/var/cache$ apt-cache search libudev-dev
libudev-dev - libudev development files
zhangze@zhangze-OptiPlex-7010:/var/cache$ dpkg -l libudev-dev
dpkg-query: no packages found matching libudev-dev
//安装显示依赖不满足
zhangze@zhangze-OptiPlex-7010:/var/cache$ sudo apt-get install libudev-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libudev-dev : Depends: libudev1 (= 198-0ubuntu11) but 198-0ubuntu11.2 is to be installed
E: Unable to correct problems, you have held broken packages.
安装libudev-dev,显示依赖于共享库libudev1,而版本(= 198-0ubuntu11)指的是当前要安装包libudev-dev的版本是11,但是应该安装的是11.2这个版本,因此是要安装的libudev-dev所在仓库版本太老,而不是已安装的libudev1版本老。
去http://packages.ubuntu.com/搜索libudev-dev这个包,发现它是在security这部分中的,而系统的security开关被关闭,已经很久没有更新security的包了
因此在software & update中打开security update,再次apt-get install libudev-dev成功(也可以vim /etc/apt/sources.list添加security源)
安装完以后的最终结果是两个包全部更新到11.2版本,说明之前的问题是:libudev1已经在最新的11.2版本,而要安装的libudev-dev在原来的仓库中是老版本11的,老版本不能依赖于新版本,添加security仓库,下载的是最新版本的libudev-dev包
zhangze@zhangze-OptiPlex-7010:/var/cache$ dpkg -l libudev-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name   Version   Architecture   Description
ii  libudev-dev   198-0ubuntu11.2   amd64   libudev development files
zhangze@zhangze-OptiPlex-7010:/var/cache$ dpkg -l libudev1
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name   Version   Architecture   Description
ii  libudev1:amd64   198-0ubuntu11.2   amd64   libudev shared library
ii  libudev1:i386   198-0ubuntu11.2   i386   libudev shared library
 
本文永久更新地址:http://www.linuxdiyf.com/linux/31959.html