When I try to install gcc on Ubuntu 12.04 LTS Server with apt-get install gcc, I get the following error:

The following packages have unmet dependencies:
 gcc : Depends: cpp (>= 4:4.6.1-2ubuntu5) but it is not going to be installed
       Depends: gcc-4.6 (>= 4.6.1-1) but it is not going to be installed
       Recommends: libc6-dev but it is not going to be installed or

When I delve deeper (i.e. try to apt-get install gcc-4.6), I get:

 gcc-4.6 : Depends: gcc-4.6-base (= 4.6.1-9ubuntu3) but 4.6.3-1ubuntu5 is to be installed
           Depends: cpp-4.6 (= 4.6.1-9ubuntu3) but it is not going to be installed
           Depends: libgomp1 (>= 4.6.1-9ubuntu3) but it is not going to be installed
           Depends: libquadmath0 (>= 4.6.1-9ubuntu3) but it is not going to be installed
           Recommends: libc6-dev (>= 2.13-0ubuntu6) but it is not going to be installed

So when I try to install gcc-4.6=4.6.1-9ubuntu3 I get a list of 366 packages to remove (including e.g. apt). Which is craziness.

This is an essentially vanilla installation of Ubuntu 12.04 LTS Server (i.e. I installed nginx, python-flup, python-yaml, rsync, python-pkg-resources, lsof, fontconfig, iptables, ufw, scons, and grc).

It is very surprising to me that I cannot install gcc, so I am somewhat confused as to why attempting to install gcc fails. The only apparent fix would seem to be uninstalling 366 packages, many of which are central to the operation of Ubuntu.

Something doesn't add up, and I would be very grateful for assistance.

EDIT The above is with the latest packages of course, having used apt-get update; apt-get upgrade before attempting the above. Sorry, I should have mentioned that.

  • 1
    Have you tried sudo apt-get update
    – Tachyons
    Jun 22, 2012 at 0:52

3 Answers 3


There's a metapackage called build-essential which should install the compiler and a bunch of related/needed packages:

sudo apt-get install build-essential

The suggestion to first do sudo apt-get update is sound, this will update package lists and all versions should match nicely.

That is, however, if you didn't modify your /etc/apt/sources.list file manually. If so, then maybe some of the changes you made or repositories you added contain conflicting packages which cause the problems you see. If that's the case, please look at the file and fix the troublesome entries. Of course, if you want help doing so, you can post your sources.list file (or any fragments in /etc/apt/sources.list.d) and maybe someone can help you fix them.

  • 2
    The problem was an errant reference to oneric in the sources.list. When I removed this reference, everything installed naturally. Great suggestion to look in sources.list for the problem - Thanks - much appreciated. Jun 22, 2012 at 1:45

Try to keep going deeper:

sudo apt-get update
sudo apt-get install gcc-4.6-base cpp-4.6 libgomp1 libquadmath0 libc6-dev

First write the command:

sudo apt-get update

Then try:

sudo apt-get install gcc

I did this and it worked! You should also try it.

If it does not works then:

sudo apt-get install build-essential

Then try. I hope it will work!

  • Hi Master Programmer, welcome to askubuntu! First, when composing an answer, use the formatting tools - especially block format - to make the answer easier to follow. Secondly, pretty much the exact some answer had already been given. Be invited to take the tour and learn how to write good answers.
    – Nephente
    Oct 1, 2015 at 12:11
  • Secondly, your answer does not substantially improve upon other answers which already exist. (It doesn't qualify as "Not an Answer", but it does get this comment)
    – Thomas Ward
    Oct 1, 2015 at 12:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .