I am using opencv 3 on ubunut 12.04 and while displaying an image the error message asks me to build the library with libgtk2.0-dev. I tried sudo apt-get install libgtk2.0-dev but I get the following error.
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:~$ I have almost tried all the online solutions like here 1 and here 2 with no results. Please suggest me any means to solve the problem. I have tried installing the libpango1-dev and libcairo2-dev separately but both have broken dependencies leading to libfontconfig1-dev. Trying to install the later gives
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.Any kind of suggestion/solution is most welcome
67 Answers
Try installing all of them at the same time, like this:
sudo apt-get install libgtk2.0-dev libpango1-dev libcairo2-dev libfontconfig1-dev Sometimes the package dependencies are related to packages out of x86_64 architecture. Try these following steps:
sudo dpkg --add-architecture i386sudo apt-get updatesudo apt-get install libgtk2.0-dev
I hope to help you.
Unable to correct problems, you have held broken packages.
That line from the output you received (when trying to install libgtk2.0-dev) seems to indicate you need to fix broken and missing packages.
Try this:
sudo apt-get update && sudo apt-get upgrade --fix-missing --fix-brokenThen, assuming that was successful, you should be able to run the install command for libgtk2.0-dev without any problems
sudo apt-get install libgtk2.0-devIf it still doesn't work, try looking for what packages are being held back:
dpkg --get-selections | grep holdIf that command gives you any output (should be package names of whatever packages are being held) try this:
sudo apt-get install <packagename>Then try to install libgtk2.0-dev again.
If it still fails, perhaps consider doing a dist-upgrade
sudo apt-get dist-upgradeI hope this helps!
1Pretty simple issue -
libfontconfig1-dev : Depends: libfontconfig1 (= 2.8.0-3ubuntu9.1) but 2.10.1-0ubuntu3 is to be installed
You have libfontconfig1 2.10.1-0ubuntu3 from 12.10 installed but are on 12.04. So you'd need to replace that package with the 12.04 version & any other 12.10 package(s) you have installed that could cause conflicts. So good luck there...
apt-cache policy libfontconfig1 & or apt-cache madison libfontconfig1 should show this clearly
Test this:
Download this files to 32 bits:
Or download this files to 64 bit:
Install them with the command:
sudo dpkg --force-all -i *.debExecuted in the download directory
I had the same issue trying to install Wireshark 1.7.0 on my Ubuntu 12.04 - wireshark requires libgtk2.0-dev.
Everything is stuck because of the package libfontconfig1-dev:
- Add the precise-updates deb server in your
/etc/apt/sources.list. For France:
deb precise-updates main restricted- Refresh
aptitude:
apt-get update- Now you can install the broken package
apt-get install libfontconfig1-dev- Put all problematic packages on the same command line. Here:
apt-get install libgtk2.0-dev libpango1.0-dev libcairo2-dev I ran into this issue on 16.04 and the reason (for me at least) was that libcairo2-dev required on a specific version of libcairo-gobject2 and I had a newer one:
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.
The following packages have unmet dependencies: libcairo2-dev : Depends: libcairo-gobject2 (= 1.14.6-1) but 1.15.2-0intel1 is to be installed
E: Unable to correct problems, you have held broken packages.So the fix was:
sudo apt-get install libcairo-gobject2=1.14.6-1Which then allowed me to install libgtk2.0-dev
The real proper fix is for the maintainers of libcairo2-dev/libcairo-gobject2 to properly fix their dependency is that one can use later version of libcairo2-gobject2.