ubuntu 12.04 libudev-dev因为依赖而无法安装

Joh*_*hnA 7 usb ubuntu udev

我有一些示例c ++代码,它使用udev库接收hotplug事件.它在Ubuntu 10.04中运行良好.它的唯一先决条件是libudev-dev包:sudo apt-get install 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.
Run Code Online (Sandbox Code Playgroud)

这似乎意味着我应该安装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.
Run Code Online (Sandbox Code Playgroud)

我不知道怎么从这里开始.libudev-dev依赖于libudev0,但已经存在,所以......下一步是什么?

请注意,sources.list中未注释以下repos,我已完成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
Run Code Online (Sandbox Code Playgroud)

有些网站表示我应该做-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.
Run Code Online (Sandbox Code Playgroud)

在这里找到了一个很好的链接:https: //askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies 但没有快乐.

谷歌说这对其他人来说是一个扣篮......

谢谢你对此有任何帮助,约翰

Joh*_*hnA 14

这是解决方案.

阅读以下内容时:

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.
Run Code Online (Sandbox Code Playgroud)

这意味着我尝试安装的libudev-dev包取决于包:

libudev0 version 175-0ubuntu9
Run Code Online (Sandbox Code Playgroud)

(这就是" (= 175-0ubuntu9) "试图说的)

但已经安装了libudev0版本175-0ubuntu9.3.

(这就是" 但是要安装175-0ubuntu9.3 "试图说).

换句话说:

  • 已安装较新版本的libudev0.
  • 我试图安装的libudev-dev软件包取决于较早版本的libudev0,它已经安装好了.
  • 这反过来意味着我安装libudev-dev的存储库已经过时了.

您可以在/etc/apt/sources.list中列出的所有存储库中找到可用的软件包:

sudo apt-cache madison libudev-dev
sudo apt-cache madison libudev0
Run Code Online (Sandbox Code Playgroud)

所以最后我们得到了真正的问题!我在sources.list中的存储库列表缺少包含libudev-dev 175-0ubuntu9.3的存储库.

要解决这个问题:

  1. 转到http://packages.ubuntu.com并搜索"libudev-dev"

  2. 在结果列表中找到175-0ubuntu9.3 for Precise Pangolin(ubuntu 12.04).在这种情况下,该版本在"exact-udpates"下.您可以点击链接:

    http://packages.ubuntu.com/precise-updates/libudev-dev

    它显示了您想要了解的有关libudev-dev的所有信息.除了它没有显示我应该使用的确切回购网址!所以我要稍微猜一下......

  3. 添加repos到apt

    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
    
    Run Code Online (Sandbox Code Playgroud)
  4. 刷新

    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
    
    Run Code Online (Sandbox Code Playgroud)
  5. 安装包:

    sudo apt-get install libudev-dev
    
    Run Code Online (Sandbox Code Playgroud)

    这就像一个魅力!

约翰