Have found this question multiple times on the forum, but none of the answers were serious enough. So the problem with ubuntu 12.04. LTS server is that after a fresh install you can not install build-essential package. This is what you get:

Reading package lists...
Building dependency tree...
Reading state information...
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: libc6-dev but it is not going to be installed or
                   Depends: g++ (>= 4:4.4.3) but it is not going to be installed

Things that DON'T help:

apt-get clean
apt-get update
apt-get -f install
apt-get upgrade
dpkg --configure -a
apt-get autoclean
apt-get --fix-missing install build-essential

apt does say that I have "held broken packages", but none of the above commands solves them. After running any of the above commands the summary at the bottom is all zeros (upgraded, newly installed, remove, not upgraded)

uname -a gives:

Linux sorrg01lin 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:42:40 UTC 2014 i686 i686 i386 GNU/Linux

lsb_release -a gives:

Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:    12.04
Codename:   precise

marked as duplicate by Avinash Raj, Jorge Castro, Aditya, souravc, Warren Hill Mar 12 '14 at 16:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Yes, found that post too, but as I mentioned those commands do not help me. The only one I have not tried is dist-upgrade, because I want to stick with 12.04. But forgot to mention I have no X, and if possible don't want to install it just make apt work – tom Mar 12 '14 at 12:19
  • sorry my mistake. found this post which cleared everything for me. askubuntu.com/questions/223237/… – tom Mar 12 '14 at 15:19
  • what part of that question answered it for you? I have the same problem and it's not clear what the answer is – Anentropic Nov 19 '14 at 15:31
  • sorry don't quite remember the exact solution but running 'apt-get -f install' and 'dpkg --configure -a' helped for sure – tom Nov 21 '14 at 6:53
  • 2
    in my case I was running from a Dockerfile, removing this line from it fixed for me RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list – Anentropic Nov 21 '14 at 10:15