在 ubuntu Ubuntu 12.04 上安装 gcc 时出错

在 ubuntu Ubuntu 12.04 上安装 gcc 时出错

我想在 ubuntu 机器上安装 gcc 但出现以下错误:

   t@lab45:~# apt-get install build-essential
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    You might want to run 'apt-get -f install' to correct these:
    The following packages have unmet dependencies:
     build-essential : Depends: libc6-dev but it is not going to be installed or                        
                                libc-dev 
                       Depends: gcc (>= 4:4.4.3) but it is not going to be installed           
                       Depends: g++ (>= 4:4.4.3) but it is not going to be installed
                       Depends: make but it is not going to be installed
                       Depends: dpkg-dev (>= 1.13.5) but it is not going to be installed
     linux-image-generic-pae : Depends: linux-image-3.2.0-37-generic-pae but it is not going to be installed
    E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

问题类似于 在 Ubuntu 12.04 LTS 上安装 gcc 但那里的解决方案并不可行。

如何处理?谢谢!

答案1

您应该确保您main的文件中已激活存档sources.list并且没有任何包被搁置。

sudo apt-get update
sudo apt-get clean
grep -P 'main&precise-updates' /etc/apt/sources.list
## Here should return something like deb http://ubuntu.mirror.cambrium.nl/ubuntu/ precise-updates main
echo $(dpkg --get-selections | grep hold | awk '{print $1}') install | sudo dpkg --set-selections
sudo apt-get upgrade
sudo apt-get --fix-missing install build-essentials

这样,您的安装就应该完美无缺了。

相关内容