How to install GCC/G++ 8 on CentOS

别来无恙 提交于 2020-08-21 05:32:07

问题


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?


回答1:


CentOS 8 already comes with GCC 8.

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

Then you can install GCC 8 and its C++ compiler:

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

To switch to a shell which defaults gcc and g++ to this GCC version, use:

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. For example, you could use the scl command to invoke a shell script that performs the required actions.




回答2:


Permanently adding DTS to your development environment

After installing the devtoolset:

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

You can also use the following command, to make DTS the default:

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:

scl enable devtoolset-8 -- bash


来源:https://stackoverflow.com/questions/55345373/how-to-install-gcc-g-8-on-centos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!