在ubuntu 22.04上安装gcc7

4 gcc 22.04

我想在 Ubuntu 22.04 上安装 gcc-7。

我用了:

sudo apt-get install gcc-7 g++-7
Run Code Online (Sandbox Code Playgroud)

但得到了错误:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package g++-7 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package gcc-7 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gcc-7' has no installation candidate
E: Package 'g++-7' has no installation can
Run Code Online (Sandbox Code Playgroud)

如何将其安装到我的机器上?

亲切的问候

迪达特

小智 12

感谢@Knud Larsen 提供的解决方案。

我遇到了同样的问题,我需要 distcc 服务器的旧版本。客户端系统、弱工业PC无法更新。

所以解决办法很简单,我没有想到,但它有效。为了记录,我添加了:

deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe
Run Code Online (Sandbox Code Playgroud)

到 /etc/apt/sources.list 和

跑:apt update; apt install g++-7

  • 对于看到此内容的任何人,**请小心执行此操作。** 在同一安装上混合使用两个版本的 Ubuntu 可能是一个非常糟糕的主意(尽管不可否认,在某些情况下我确实犯了这样做)。我很难想象这会出错,但做这样的事情可能会让你爆炸。 (2认同)