5

After Upgrading to Ubuntu 18.04 from 16.04 build-essential, g++, gcc & cpp E: Unable to correct problems, you have held broken packages.

$ sudo apt-get install build-essential
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:
 build-essential : Depends: gcc (>= 4:7.2) but it is not going to be installed
                   Depends: g++ (>= 4:7.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.


$ sudo apt-get install gcc
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:
 gcc : Depends: gcc-7 (>= 7.3.0-12~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

The same type of output for g++ & cpp

How to fix this?

  • I'm getting this same error now (2018/12/10), even though I've removed all 3rd party PPAs. – warsong Dec 10 '18 at 13:57
2

I've encountered the same - on Ubuntu 16.04 I had the Toolchain Test Builds PPA for gcc and clang builds, including gcc-7. During the upgrade to 18.04, 3rd party repositories were disabled by the installation process, with this PPA included.

To fix this, try (re?)adding the toolchain PPA to your apt sources list:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update

Then, when installing build-essential, it should successfully pick gcc-7 from the toolchain PPA.

  • 1
    This didn't work for me, it still says gcc-7 cannot be found. – void.pointer Jul 18 '18 at 17:38
  • 1
    this doesn't work for me either, same error as void.pointer – warsong Dec 10 '18 at 14:02
2

I had the same issue, but apparently I had used a different PPA when I installed those tools.

For me I fixed it with:

sudo add-apt-repository ppa:jonathonf/gcc

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.