我有一些使用 udev 库接收热插拔事件的示例 C++ 代码。它在 Ubuntu 10.04 中运行良好。唯一的先决条件是 libudev-dev 包:
须藤 apt-get 安装 libudev-dev
但是当我尝试在 12.04 中安装该软件包时,我得到:
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: libudev0 (= 175-0ubuntu9) but 175-0ubuntu9.3 is to be installed
E: Unable to correct problems, you have held broken packages.
这似乎暗示我应该安装 libudev0,所以:
sudo apt-get install libudev0
Reading package lists... Done
Building dependency tree
Reading state information... Done
libudev0 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
我不知道如何从这里开始。 libudev-dev 依赖于 libudev0 但它已经到位,所以......接下来是什么?
请注意,sources.list 中未注释以下存储库,并且我已经完成了 apt-get 更新:
deb http://us.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ precise main restricted
deb http://us.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://us.archive.ubuntu.com/ubuntu/ precise universe
一些网站表明我应该做 -f:
sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
在这里找到了一个很好的链接:
https://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies
但没有快乐。
谷歌说这对其他人来说是一次扣篮......
感谢您对此的任何帮助,
约翰
最佳答案
这是解决方案。
当您阅读以下内容时:
The following packages have unmet dependencies:
libudev-dev : Depends: libudev0 (= 175-0ubuntu9) but 175-0ubuntu9.3 is to be installed
E: Unable to correct problems, you have held broken packages.
这意味着我尝试安装的 libudev-dev 包依赖于包:
libudev0 version 175-0ubuntu9
(这就是“ (= 175-0ubuntu9) ”想要表达的意思)
但是已经安装了 libudev0 版本 175-0ubuntu9.3。
(这就是“ 但 175-0ubuntu9.3 将被安装 ” 试图说的)。
所以换句话说:
您可以通过以下方式在当前在/etc/apt/sources.list 中列出的所有存储库中找到可用的软件包:
sudo apt-cache madison libudev-dev
sudo apt-cache madison libudev0
所以最后我们解决了真正的问题!我在 sources.list 中的存储库列表缺少包含 libudev-dev 175-0ubuntu9.3 的存储库。
要解决这个问题:
http://packages.ubuntu.com/precise-updates/libudev-dev
它显示了您想了解的有关 libudev-dev 的所有信息。除了它没有显示我应该使用的确切 repo url!所以我要猜一下...
sudo gedit /etc/apt/sources.list
[ add these two repos ]
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates main
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates main
sudo apt-get update
sudo apt-cache madison libudev-dev
[you should see libudev-dev 175-0ubuntu9.3 in the output]
libudev-dev | 175-0ubuntu9.3 | http://us.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
sudo apt-get install libudev-dev
这就像一个魅力!
约翰
关于由于依赖关系,ubuntu 12.04 libudev-dev 不会安装,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17181073/