Unable to install GCC, depends gcc-7

11,354

Vijay's comment fixed my problem. Thank you Vijay.

The answer is here.

That particular error message may indicate that you have held packages, but it may also indicate a different problem.

You can get a list of actual held packages with:

dpkg --get-selections | grep hold

If there are none, or none look related, then it's probably something else. Check carefully the output of the command you were trying when you got the error message, as there may be other clues in the full output from that command, aside from the error message.

Another method of troubleshooting may be to use aptitude rather than apt-get to try to install your package:

sudo aptitude install gcc

Aptitude will give up less easily, and will attempt to find solutions which may involve modifying other packages. It may give you more explanation of the problem and options for fixing it.

Occasionally aptitude will be too eager to remove or downgrade large numbers of packages to satisfy your request, in which case retrying with -f changes its priorities and helps it come up with solutions that involve removing/downgrading fewer packages even if it means not all changes you requested can go ahead:

sudo aptitude -f install gcc

The last two options fixed my problem, i hope that it helps someone else too.

Share:
11,354

Related videos on Youtube

Bane Mikic
Author by

Bane Mikic

Updated on September 18, 2022

Comments

  • Bane Mikic
    Bane Mikic almost 2 years

    When i try to compile in Geany i get the following error:

    /bin/sh: 1: gcc: not found

    When I run

    sudo apt install gcc
    

    This is what is printed on the screen:

    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
           Recommends: libc6-dev but it is not going to be installed or
                       libc-dev
    E: Unable to correct problems, you have held broken packages.
    

    I am using Ubuntu 18.04.1 LTS

    • Vijay
      Vijay over 5 years
    • George Udosen
      George Udosen over 5 years
      Please run sudo apt install -f and try again!