无法在ubuntu 20.04中安装g++和build-essentials

dfty9e19  于 2022-11-02  发布在  其他
关注(0)|答案(5)|浏览(1032)

即使用apt-get clean清理后,它也会说有损坏的包。[1]中提到的sudo dpkg -l | grep ^..r什么也不返回。

$ 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:9.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

[1][https://www.techbrown.com/fix-broken-packages-ubuntu-debian/](https://www.techbrown.com/fix-broken-packages-ubuntu-debian/)

3hvapo4f

3hvapo4f1#

TL;DR:必须降级libc6,然后才能安装build-essential
经历了同样的事情:

$ sudo apt 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:9.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我是这么做的。
检查了apt-cache policy g++,我认为这已经令人满意,所以我继续:

$ apt-cache policy g++
g++:
  Installed: (none)
  Candidate: 4:9.3.0-1ubuntu2
  Version table:
     4:9.3.0-1ubuntu2 500
        500 http://mirrors.xtom.com/ubuntu focal/main amd64 Packages

已检查apt-cache policy libc6-dev

$ apt-cache policy libc6-dev
libc6-dev:
  Installed: (none)
  Candidate: 2.31-0ubuntu9.2
  Version table:
     2.31-0ubuntu9.2 500
        500 http://mirrors.xtom.com/ubuntu focal-updates/main amd64 Packages
     2.31-0ubuntu9 500
        500 http://mirrors.xtom.com/ubuntu focal/main amd64 Packages

已尝试安装特定版本(上面显示的最新版本):

$ sudo apt install libc6-dev=2.31-0ubuntu9.2
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.31-0ubuntu9.2) but 2.31-0ubuntu9.3 is to be installed
E: Unable to correct problems, you have held broken packages.

做了同样的事情,尝试安装特定的libc6版本:

$ sudo apt install libc6=2.31-0ubuntu9.2
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  glibc-doc
The following packages will be DOWNGRADED:
  libc6
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 2,715 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
...
dpkg: warning: downgrading libc6:amd64 from 2.31-0ubuntu9.3 to 2.31-0ubuntu9.2
...

强调我得到的警告:dpkg: warning: downgrading libc6:amd64 from 2.31-0ubuntu9.3 to 2.31-0ubuntu9.2
现在我可以安装build-essential了:

$ sudo apt install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  g++ g++-9 libc-dev-bin libc6-dev libcrypt-dev libstdc++-9-dev linux-libc-dev manpages-dev
Suggested packages:
  g++-multilib g++-9-multilib gcc-9-doc glibc-doc libstdc++-9-doc
The following NEW packages will be installed:
  build-essential g++ g++-9 libc-dev-bin libc6-dev libcrypt-dev libstdc++-9-dev linux-libc-dev manpages-dev
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 16.2 MB of archives.
After this operation, 77.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]

我读了多个不同的stackoverflow帖子,导致我使用了我不熟悉的apt-cache policy $package。然后我只是到处玩。

abithluo

abithluo2#

在寻找答案后,我决定手动安装“正确”的版本,并在下载pkg文件时遇到了这个问题:
将以下行添加到/etc/apt/sources.list中:

deb http://archive.ubuntu.com/ubuntu/ focal-proposed main

更新软件包索引:

sudo apt-get update

在添加了这个存储库之后,我能够使用以下命令安装build-essential:

sudo apt-get install build-essential
u5rb5r59

u5rb5r593#

我想我偶然发现了一个超级简单的解决方案。没有降级或内核构建。只是运行

sudo apt update && sudo apt upgrade -y

在我的案例中有3个仓库返回错误,

E: The repository 'cdrom://Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423) focal Release' does not have a Release file.

刚启动软件更新程序,删除了出现错误的PPA,现在我可以安装新软件,而无需

Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed

错误。

klsxnrf1

klsxnrf14#

我在Ubuntu 22.04 LTS中遇到了类似的问题当我使用sudo apt install build-essential时,

错误:

...
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.35-0ubuntu3) but 2.35-0ubuntu3.1 is to be installed
             Depends: libtirpc-dev but it is not going to be installed
             Depends: libnsl-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

**解决方案:**我尝试使用命令降级软件包

sudo apt install libc6=2.35-0ubuntu3

但是,它并没有解决问题,并导致最后一个错误:

...
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:
 libtirpc-dev : Depends: libtirpc3 (= 1.3.2-2build1) but 1.3.2-2ubuntu0.1 is to be installed
E: Unable to correct problems, you have held broken packages.

**解决方案:**因此,我再次将错误包降级

sudo apt-get install libtirpc3=1.3.2-2build1

现在,问题终于解决了,我可以用
第一个

2w3rbyxf

2w3rbyxf5#

您必须从Software & Updates申请“规范合作伙伴”支持。
Software & Updates of Ubuntu20
在Canonical Partners(而不是源代码)中标记“√”,然后执行

sudo apt install build-essential

相关问题