我正在尝试在 Ubuntu 16.04(Xenial Xerus)上安装 build-essential 包,但存在依赖性问题。
root@server:~# 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: gcc (>= 4:5.2) but it is not going to be installed
Depends: g++ (>= 4:5.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
当我尝试的时候,
root@server:~# apt-get install 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-0ubuntu2) but 2.23-0ubuntu3 is to be installed
E: Unable to correct problems, you have held broken packages.
并且;
root@server:~# apt-cache policy libc6-dev
libc6-dev:
Installed: (none)
Candidate: 2.23-0ubuntu2
Version table:
2.23-0ubuntu2 500
500 http://tr.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
root@server:~# apt-cache policy gcc
gcc:
Installed: (none)
Candidate: 4:5.3.1-1ubuntu1
Version table:
4:5.3.1-1ubuntu1 500
500 http://tr.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
root@server:~# apt-cache policy g++
g++:
Installed: (none)
Candidate: 4:5.3.1-1ubuntu1
Version table:
4:5.3.1-1ubuntu1 500
500 http://tr.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
答案1
土耳其 repo 存在一些问题。您可以更改 /etc/apt/sources.list 文件。
替换所有行 http://tr.archive.ubuntu.com/ubuntu 到 http://archive.ubuntu.com/ubuntu
并执行 sudo apt-get update; sudo apt-get upgrade
答案2
libc6-dev:依赖:libc6(= 2.23-0ubuntu2)但需要安装 2.23-0ubuntu3
libc6 和 libc6-dev 需要是相同的版本,但是 apt 设置使用的镜像上的 libc6-dev 版本比系统上的 libc6 版本旧,并且 apt 通常不会降级软件包。
在这种情况下,您的问题似乎是镜像严重过时(2.23-0ubuntu3 已在 xenial 中存在一周多了)。我建议您更改 sources.list 以指向不同的镜像。
当有人将 sources.list 更改为较新的版本、安装一些内容并将其改回时,您也会遇到此问题,但在这种情况下,您通常会看到更大的版本差异。