6

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

  • 1
    What does sudo apt-get install -f show, after you try to install libgtk2.0-dev? – Pilot6 May 25 '15 at 13:44
  • Try this link: OpenCV installation for Ubuntu 12.04. – spacegeek224 May 28 '15 at 4:17
  • please post the output of apt-cache policy libfontconfig1 – g_p May 29 '15 at 5:19
  • Can you force it to install the required version of libfontconfig? sudo apt-get install libfontconfig1=2.8.0 It should be in the precise repository. Or you can download and install it with sudo dpkg -i /PATH/TO/FILE.deb from here. – Byte Commander May 29 '15 at 20:09
  • Sometimes this happens because the package you need is a 32 bits version. Try to install that. – Calcius May 30 '15 at 14:29
1

Pretty 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

2

Try installing all of them at the same time, like this:

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

Sometimes the package dependencies are related to packages out of x86_64 architecture. Try these following steps:

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

I hope to help you.

2

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-broken

Then, 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-dev

If it still doesn't work, try looking for what packages are being held back:

dpkg --get-selections | grep hold

If 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-upgrade

I hope this helps!

  • This worked for me on Rasbian Stretch while trying to install OpenCV – James Nicholson Nov 13 '17 at 8:41
1

Test this:

Download this files to 32 bits:

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

Or download this files to 64 bit:

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

Install them with the command:

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

Executed in the download directory

1

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:

  1. Add the precise-updates deb server in your /etc/apt/sources.list . For France:
deb http://fr.archive.ubuntu.com/ubuntu/ precise-updates main restricted
  1. Refresh aptitude:
apt-get update
  1. Now you can install the broken package
apt-get install libfontconfig1-dev
  1. Put all problematic packages on the same command line. Here:
apt-get install libgtk2.0-dev libpango1.0-dev libcairo2-dev
0

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-1

Which 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.