无法安装 build-essential,持有损坏的软件包

And*_* Ge 3 apt gcc g++ software-installation

所以我试图设置我的计算机进行开发。我安装了 ubuntu 14.04 LTS。我想编写一个 hello-world 程序。但是我无法编译它。经过一番搜索,我尝试了sudo apt-get install build-essential,它抱怨:

>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: g++ (>= 4:4.4.3) but it is not going to be installed
                   Depends: dpkg-dev (>= 1.13.5) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)

我尝试更改来源和sudo apt-get update, sudo apt-get upgrade,但问题仍然存在。我试过sudo apt-get autocleansudo apt-get install --fix-broken或者类似的东西,没有一个有效。

另外,我试过sudo aptitude why-not build-essential,它说:

>sudo aptitude why-not build-essential
p   gvfs-bin:i386          Provides   gvfs-bin                         
p   gvfs-bin:i386          Suggests   gvfs:i386                        
p   gvfs:i386              Suggests   gvfs-backends:i386               
p   gvfs-backends:i386     Depends    libgphoto2-port10:i386 (>= 2.5.2)
p   libgphoto2-port10:i386 Suggests   gphoto2:i386 (> 2.1.0)           
p   gphoto2:i386           Suggests   gthumb:i386                      
p   gthumb:i386            Recommends flex:i386                        
p   flex:i386              Suggests   build-essential:i386             
p   build-essential:i386   Conflicts  build-essential 
Run Code Online (Sandbox Code Playgroud)

那么这里有什么问题呢?

还有我的sources.list文件:

>cat /etc/apt/sources.list
# deb cdrom:[Ubuntu 14.04.4 LTS _Trusty Tahr_ - Release amd64 (20160217.1)]/ trusty main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.163.com/ubuntu/ trusty main restricted
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted

## Major bug fix updates produced after the final release of the
## distribution.

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.163.com/ubuntu/ trusty universe
deb-src http://mirrors.163.com/ubuntu/ trusty universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.163.com/ubuntu/ trusty multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.


## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu trusty partner
# deb-src http://archive.canonical.com/ubuntu trusty partner

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main
Run Code Online (Sandbox Code Playgroud)

我的sources.list.d目录:

>ls -la /etc/apt/sources.list.d
total 8
drwxr-xr-x 2 root root 4096  4? 10  2014 .
drwxr-xr-x 6 root root 4096  4? 14 14:16 ..
Run Code Online (Sandbox Code Playgroud)

顺便说一句,谁能简要解释一下什么是破损的包裹以及为什么它如此容易出现?或者可能的原因是什么/为什么会发生这种情况?apt-get 不应该能够解决这些问题,或者至少在这里提供一些有用的信息吗?我最近多次遇到此错误,但找不到任何解决方案。

非常感谢。

And*_* Ge 6

经过一段时间的挣扎,我找到了解决此问题的方法。

首先sudo apt-get install aptitude,它工作正常。然后 try sudo aptitude install build-essential,它首先说有问题并提出解决方案。它提出的第一个解决方案保持不变,这不是我们想要的,所以选择no。它提出了第二种解决方案,它会起作用。

顺便说一句,我仍然很困惑,为什么我会在新安装的 ubuntu 系统上“持有损坏的包”?“持有破损的包裹”是什么意思?

  • 我遇到了同样的问题,我在所有论坛上应用了每条建议,但所有建议都没有用。我按照你的方式做了!谢啦。 (3认同)