gcc-11何时会出现在Ubuntu存储库中?

GCC 11.1 终于在昨天发布了。但是,现在它只能从源代码构建,所以我想知道我们什么时候可以使用它apt

回答

在 Ubuntu 20.04 上,我按照此处的说明进行操作:

  • https://packages.ubuntu.com/hirsute/amd64/gcc-11-multilib/download

这是为了:

  1. 通过在 /etc/apt/sources.list 中添加一行来更新列出的镜像,如下所示:

    sudo add-apt-repository 'deb http://mirrors.kernel.org/ubuntu hirsute main universe'

    从列表中根据您的位置选择镜像。我选择了内核镜像,因为我在北美。

  2. sudo apt-get update

  3. 须藤 apt-get 安装 gcc-11

之后which gcc-11应该会生成一条通往 gcc-11 的路径。在我的机器上是:

which gcc-11

产生:/usr/bin/gcc-11

  • Be very careful, don't run 'apt-get upgrade' or your 20.04 becomes 21.04, it's safer to remove the sources.list line after gcc-11 is installed so you don't ended up upgrading all your packages to a new ubuntu release by accident, which could take quite a while.
  • 这是完全安全的吗?如果添加 hirsute repo 使 GCC-11 可用,我们难道不应该期望它提供许多可能与 20.04 不兼容的其他更新包吗?
  • 这不是一个安全的答案,因为它可能会在 Focal 中造成一堆包,这些包本来是 Focal 而不是 Hirsuite。如果您想要 Focal 中的 Hirsuite 版本(例如,用于构建最新内核的 dwarves 或 libbpf),最好使用 GCC 和 Focal 中的 C 库重新构建它们。否则升级到 Hirsuite 或更高版本。

回答

sudo apt install build-essential manpages-dev software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update && sudo apt install gcc-11 g++-11

然后使用update-alternatives设置默认gcc ...

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-9 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-9  --slave /usr/bin/cpp cpp /usr/bin/cpp-9 && 

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11  --slave /usr/bin/cpp cpp /usr/bin/cpp-11;

要对设置进行示例检查以查看默认的 gcc,您可以运行以下命令,如果它们显示正确的结果,则其余的都很好...

gcc --version;g++ --version;gcov --version;

要重新配置为任何以前的 gcc 版本...

sudo update-alternatives --config gcc

您可以在任何版本的 ubuntu 上执行此操作,...享受吧!

这是我的 6 个不同的 gcc 并排的,默认是 gcc-11:

$ sudo update-alternatives --config gcc
There are 6 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-11   1010      auto mode
  1            /usr/bin/gcc-10   1000      manual mode
  2            /usr/bin/gcc-11   1010      manual mode
  3            /usr/bin/gcc-5    40        manual mode
  4            /usr/bin/gcc-7    700       manual mode
  5            /usr/bin/gcc-8    800       manual mode
  6            /usr/bin/gcc-9    900       manual mode

Press <enter> to keep the current choice[*], or type selection number:

  • Works for me that's why I wrote it. Perhaps you should elaborate to get more help.
  • The "doesn't work" comment may be due to a missing `sudo apt update` after adding the repo.
  • 如何修复错误:替代 cpp 不能成为 gcc 的从属:它是主替代?

以上是gcc-11何时会出现在Ubuntu存储库中?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>