简体   繁体   English

如何在 CentOS 上安装 GCC/G++ 8

[英]How to install GCC/G++ 8 on CentOS

I'm used to install packages on Debian/Ubuntu distributions, but now I need to install gcc and g++ version 8.*.我习惯于在 Debian/Ubuntu 发行版上安装软件包,但现在我需要安装gccg++版本 8.*。 There is only version 4.* in CentOS repositories. CentOS 软件库中只有 4.* 版本。 What's the correct way to install them manually?手动安装它们的正确方法是什么?

CentOS 8 already comes with GCC 8. CentOS 8 已经带有 GCC 8。

On CentOS 7, you can install GCC 8 from Developer Toolset.在 CentOS 7 上,您可以从 Developer Toolset 安装 GCC 8。 First you need to enable the Software Collections repository:首先,您需要启用 Software Collections 存储库:

yum install centos-release-scl

Then you can install GCC 8 and its C++ compiler:然后你可以安装 GCC 8 和它的 C++ 编译器:

yum install devtoolset-8-gcc devtoolset-8-gcc-c++

To switch to a shell which defaults gcc and g++ to this GCC version, use:要切换到默认gccg++到此 GCC 版本的 shell,请使用:

scl enable devtoolset-8 -- bash

You need to wrap all commands under the scl call, so that the process environment changes performed by this command affect all subshells.您需要将所有命令都包装在scl调用下,以便此命令执行的进程环境更改会影响所有子 shell。 For example, you could use the scl command to invoke a shell script that performs the required actions.例如,您可以使用scl命令调用执行所需操作的 shell 脚本。

Permanently adding DTS to your development environment 将 DTS 永久添加到您的开发环境

After installing the devtoolset:安装 devtoolset 后:

yum install devtoolset-8-gcc devtoolset-8-gcc-c++

You can also use the following command, to make DTS the default:您还可以使用以下命令将 DTS 设为默认值:

source scl_source enable devtoolset-8

The benefit of this command is that it can be added to .bashrc , so that you don't have to run the scl command every time you login:这个命令的好处是可以添加到.bashrc 中,这样就不用每次登录都运行 scl 命令:

scl enable devtoolset-8 -- bash

CentOS 8, to install dev tools: sudo dnf groupinstall "Development Tools" CentOS 8,安装开发工具: sudo dnf groupinstall "Development Tools"

https://linuxhint.com/install_gcc_build_tools_centos8/ https://linuxhint.com/install_gcc_build_tools_centos8/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM