如何在 CentOS 上安装 GCC/G++ 8 [英] How to install GCC/G++ 8 on CentOS
问题描述
我习惯在 Debian/Ubuntu 发行版上安装软件包,但现在我需要安装 gcc
和 g++
版本 8.*.CentOS 软件库中只有版本 4.*.手动安装它们的正确方法是什么?
I'm used to install packages on Debian/Ubuntu distributions, but now I need to install gcc
and g++
version 8.*. There is only version 4.* in CentOS repositories. What's the correct way to install them manually?
推荐答案
CentOS 8 已经自带 GCC 8.
CentOS 8 already comes with GCC 8.
在 CentOS 7 上,您可以从 Developer Toolset 安装 GCC 8.首先,您需要启用 Software Collections 存储库:
On CentOS 7, you can install GCC 8 from Developer Toolset. First you need to enable the Software Collections repository:
yum install centos-release-scl
然后您可以安装 GCC 8 及其 C++ 编译器:
Then you can install GCC 8 and its C++ compiler:
yum install devtoolset-8-gcc devtoolset-8-gcc-c++
要切换到默认 gcc
和 g++
到此 GCC 版本的 shell,请使用:
To switch to a shell which defaults gcc
and g++
to this GCC version, use:
scl enable devtoolset-8 -- bash
您需要将所有命令包装在 scl
调用下,以便该命令执行的进程环境更改影响所有子shell.例如,您可以使用 scl
命令调用执行所需操作的 shell 脚本.
You need to wrap all commands under the scl
call, so that the process environment changes performed by this command affect all subshells. For example, you could use the scl
command to invoke a shell script that performs the required actions.
这篇关于如何在 CentOS 上安装 GCC/G++ 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!