Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.*. There is only version 4.* in CentOS repositories. What's the correct way to install them manually?

like image 882
Eenoku Avatar asked Mar 25 '19 19:03

Eenoku


People also ask

Does CentOS come with GCC?

The default CentOS repositories contain a package group named Development Tools that contains the GCC compiler and a lot of libraries and other utilities required for compiling software.


1 Answers

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.

like image 91
Florian Weimer Avatar answered Sep 28 '22 08:09

Florian Weimer