下载此文件至 32 位:

下载此文件至 32 位:

我在 ubunut 12.04 上使用 opencv 3,在显示图像时,错误消息要求我使用 libgtk2.0-dev 构建库。我试过了sudo apt-get 安装 libgtk2.0-dev但我收到以下错误。

teraflops@teraflops-Inspiron-3542:~$ sudo apt-get install libgtk2.0-devReading 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:
 libgtk2.0-dev : Depends: libpango1.0-dev (>= 1.20) but it is not going to be installed
                 Depends: libcairo2-dev (>= 1.6.4-6.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
teraflops@teraflops-Inspiron-3542:~$ 

我几乎尝试了所有在线解决方案,例如这里 1这里 2没有结果。请建议我解决问题的任何方法。我尝试安装libpango1-devlibcairo2-dev但两者都存在破坏的依赖关系,导致libfontconfig1-dev尝试安装后者

teraflops@teraflops-Inspiron-3542:~$ sudo apt-get install libfontconfig1-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:
 libfontconfig1-dev : Depends: libfontconfig1 (= 2.8.0-3ubuntu9.1) but 2.10.1-0ubuntu3 is to be installed
E: Unable to correct problems, you have held broken packages.

欢迎任何建议或解决方案

答案1

尝试同时安装所有这些,如下所示:

sudo apt-get install libgtk2.0-dev libpango1-dev libcairo2-dev libfontconfig1-dev

答案2

有时软件包依赖关系与 x86_64 架构之外的软件包相关。请尝试以下步骤:

  1. sudo dpkg --add-architecture i386
  2. sudo apt-get update
  3. sudo apt-get install libgtk2.0-dev

我希望能帮到你。

答案3

Unable to correct problems, you have held broken packages.

您收到的输出中的那行(当尝试安装 libgtk2.0-dev 时)似乎表明您需要修复损坏和丢失的软件包。

尝试这个:

sudo apt-get update && sudo apt-get upgrade --fix-missing --fix-broken

然后,假设成功了,你应该能够毫无问题地运行 libgtk2.0-dev 的安装命令

sudo apt-get install libgtk2.0-dev

如果仍然不起作用,请尝试查找被阻止的包:

dpkg --get-selections | grep hold

如果该命令给您任何输出(应该是正在保存的包的包名称)请尝试以下操作:

sudo apt-get install <packagename>

然后尝试再次安装 libgtk2.0-dev。

如果仍然失败,也许可以考虑进行 dist-grade

sudo apt-get dist-upgrade

我希望这有帮助!

答案4

测试一下:

下载此文件至 32 位:

http://mirrors.kernel.org/ubuntu/pool/main/g/gtk+2.0/libgtk2.0-dev_2.24.10-0ubuntu6_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gtk+2.0/gir1.2-gtk-2.0_2.24.10-0ubuntu6_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/a/atk1.0/libatk1.0-dev_2.4.0-0ubuntu1_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/c/cairo/libcairo2-dev_1.10.2-6.1ubuntu2_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-dev_2.26.1-1_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/glib2.0/libglib2.0-dev_2.32.1-0ubuntu2_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gtk+2.0/libgtk2.0-0_2.24.10-0ubuntu6_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gtk+2.0/libgtk2.0-common_2.24.10-0ubuntu6_all.deb
http://mirrors.kernel.org/ubuntu/pool/main/p/pango1.0/libpango1.0-dev_1.30.0-0ubuntu2_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/libx/libxcomposite/libxcomposite-dev_0.4.3-2build1_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/libx/libxdamage/libxdamage-dev_1.1.3-2build1_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/p/pkg-config/pkg-config_0.26-1ubuntu1_i386.deb

或者下载此文件至 64 位:

http://mirrors.kernel.org/ubuntu/pool/main/g/gtk+2.0/libgtk2.0-dev_2.24.10-0ubuntu6_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gtk+2.0/gir1.2-gtk-2.0_2.24.10-0ubuntu6_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/a/atk1.0/libatk1.0-dev_2.4.0-0ubuntu1_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/c/cairo/libcairo2-dev_1.10.2-6.1ubuntu2_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-dev_2.26.1-1_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/glib2.0/libglib2.0-dev_2.32.1-0ubuntu2_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gtk+2.0/libgtk2.0-0_2.24.10-0ubuntu6_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gtk+2.0/libgtk2.0-common_2.24.10-0ubuntu6_all.deb
http://mirrors.kernel.org/ubuntu/pool/main/p/pango1.0/libpango1.0-dev_1.30.0-0ubuntu2_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/libx/libxcomposite/libxcomposite-dev_0.4.3-2build1_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/libx/libxdamage/libxdamage-dev_1.1.3-2build1_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/p/pkg-config/pkg-config_0.26-1ubuntu1_amd64.deb

使用以下命令安装它们:

sudo dpkg --force-all -i *.deb

在下载目录下执行

相关内容