c++ - 无法在 ubuntu 20.04 中安装 g++

标签 c++ ubuntu g++ ubuntu-20.04 g++4.9

我在这个网站上看到了一些类似的问题 old latest .
但他们都没有得到答复,我无法在那里发表评论,因为我的声誉点较少。
当我运行 sudo apt install g++我收到以下错误:

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:
 g++ : Depends: gcc (= 4:9.3.0-1ubuntu2) but it is not going to be installed
       Depends: g++-9 (>= 9.3.0-3~) but it is not going to be installed
       Depends: gcc-9 (>= 9.3.0-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
当我运行 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: gcc (>= 4:9.2) but it is not going to be installed
                   Depends: g++ (>= 4:9.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我需要在 ubuntu20.04 中安装 g++。
谢谢您的帮助!

最佳答案

我通过安装 aptitude 找到了解决方法第一的。
我按照以下步骤操作:sudo apt-get install aptitude然后 aptitude 给出一个包列表(没有安装)
并要求将这些软件包保持在同一版本中。选择否 (n)。
然后 aptitude 要求降级一些软件包。选择是 (Y)。
最后运行命令:sudo aptitude install build-essential运行上述命令后g++已经安装了,我不需要单独安装它。\

关于c++ - 无法在 ubuntu 20.04 中安装 g++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72438431/

相关文章:

c++ - 如何从文本文件中读取数值直到遇到 char 类型?

c++扩展同一类的构造函数(无继承)

c++ - FFTW 性能变化

c++ - findHomography 返回的 mask 参数值代表什么?

linux - 如何检查程序是否在 Windows 上的 Ubuntu 上的 Bash 中运行,而不仅仅是普通的 Ubuntu?

c++ - G++-4.7.0 递归类型别名的内部编译器错误分段故障

android - 通过 ssh ubuntu 64 位启动 Android 模拟器时出错

postgresql - 尽管有 "unmet dependencies",但如何在 Ubuntu 16.04 VM 上安装 postgresql 以设置 Ruby on Rails 项目

c++ - 为什么 g++ 不能编译一个简单的 GTK 程序?

c++ - scoped_lock 如何避免发出 "unused variable"警告?