Ubuntu – How to fix held broken packages

package-managementUbuntu

Trying to install libssl-dev on ubuntu 14.04.2

$ make
fatal error: openssl/sha.h: No such file or directory
compilation terminated.

$ sudo apt-get install libssl-dev
The following packages have unmet dependencies:
 libssl-dev : Depends: zlib1g-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

$ sudo apt-get install zlib1g-dev
The following packages have unmet dependencies:
 zlib1g-dev : Depends: zlib1g (= 1:1.2.3.4.dfsg-3ubuntu4) but 1:1.2.8.dfsg-1ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.

How can I remove the held package and install the correct?

Best Answer

First, try entering this: sudo dpkg --configure -a

This will go a long way toward fixing broken dependencies. If that does not suffice, try: sudo apt-get install -f

Then clean and update: sudo apt-get clean && sudo apt-get update

Then upgrade: sudo apt-get upgrade (say 'y' to upgrades)

If you get a message saying some packages are "held back", do this:

sudo apt-get dist-upgrade

Now do these two commands:

sudo apt-get purge zlib1g-dev
sudo apt-get autoremove

Then see what happens when you enter: sudo apt-get install libssl-dev

If it still doesn't work, try this:

sudo aptitude install libssl-dev zliblg-dev=1:1.2.8.dfsg-1ubuntu1

If it still doesn't work, open up Synaptic Package Manager (It should be in your Launcher. If you can't find it, then at the Terminal enter synaptic-pkexec).

Search for zlib1g-dev. If the box next to zlib1g-dev is not green, click on it and select "Mark for installation". If you see more than one version, pick 1:1.2.8.dfsg-1ubuntu1 . Then search for libssl-dev. If the box next to libssl-dev is not green, click on it and select "Mark for installation".

Then select "Apply".

Related Question