安装 build-essential 时出现问题。损坏的软件包错误

安装 build-essential 时出现问题。损坏的软件包错误

我刚刚在笔记本电脑上全新安装了 Ubuntu Mate 15.10,目前我需要安装“build-essential”。我运行了:

sudo apt-get install build-essential

并收到此错误:

daniel@daniel-VGN-NR230FE:~$ sudo apt-get install build-essential 
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:
build-essential : Depends: libc6-dev but it is not going to be installed or
                        libc-dev
               Depends: g++ (>= 4:5.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我不知道这是否与此有关,但在安装过程中,我跳过了一些包,因为安装它们将花费很长时间(大约 300 分钟)。

在进行构建必需的操作之前,我安装了通过软件更新程序提供的所有更新和不完整的语言包,但再次出现此错误。

答案1

我将首先验证你的发行版的main源是否已启用,如果是 15.10,你的代码名称应该是wily

  1. 打开sources文件:

    $sudo gedit /etc/apt/sources.list

  2. 查找以下行并取消注释然后保存文件:

    ###### Ubuntu Main Repos
    deb http://us.archive.ubuntu.com/ubuntu/ wily main
    deb-src http://us.archive.ubuntu.com/ubuntu/ wily main

    ###### Ubuntu Update Repos
    deb http://us.archive.ubuntu.com/ubuntu/ wily-security main
    deb http://us.archive.ubuntu.com/ubuntu/ wily-updates main
    deb-src http://us.archive.ubuntu.com/ubuntu/ wily-security main
    deb-src http://us.archive.ubuntu.com/ubuntu/ wily-updates main

  3. 更新源并重试安装:

    $sudo apt-get update
    sudo apt-get install build-essential

答案2

对我来说,这可能是 docker 特有的。但如果它正常工作,您可以尝试一下。我在 Ubuntu 16.04 的 docker 镜像上遇到了同样的问题。我尝试安装 libc6-dev,它给出了这个错误:

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:
 libc6-dev : Depends: libc6 (= 2.23-0ubuntu10) but 2.23-0ubuntu11 is to be installed
E: Unable to correct problems, you have held broken packages.

这实际上是要求降级 libc6。降级后:

apt-get install libc6=2.23-0ubuntu10

我终于可以安装 build-essential

答案3

我遇到了类似的问题。我通过这样做解决了它:

开始之前,如果您没有 aptitude,可以按照以下说明进行安装:[aptitude 文档][1]

如果你已经拥有它,你可以继续。首先你需要运行:

sudo aptitude install g++
Accept this solution? [Y/n/q/?]

您必须选择n

它会建议您降级该软件包,并会询问以下问题:

Accept this solution? [Y/n/q/?]

这次选择Y

它将降级软件包。完成后,你现在可以按如下方式安装 build-essential:

sudo aptitude -f install build-essential
Accept this solution? [Y/n/q/?]

您必须选择Y

它将安装它。完成后,您可以运行此命令来检查它:

sudo aptitude search build-essential

如果你在结果中看到这一行:

> i   build-essential                 - Informational list of build-essential pack

这意味着安装成功,但是如果你没有看到它,那么你必须寻找其他解决方案来解决它。[1]:https://doc.ubuntu-fr.org/aptitude

答案4

遇到类似问题,通过运行解决

sudo apt-get update
sudo apt-get install -y gcc

相关内容