Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
                   libc-dev

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.

share|improve this question
1  
Have you tried sudo apt-get update –  Tachyons Jun 22 '12 at 0:52

2 Answers 2

up vote 23 down vote accepted

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.

share|improve this answer
    
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. –  Brian M. Hunt Jun 22 '12 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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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