Installing gcc versions on Centos7 / Redhat7


Centos7 and Redhat7 still uses too old gcc 4.8.5 version and this becomes very annoying if you want to use newer features in your C/C++ programs.

You can install these newer versions with Devtoolset-4 from the Software Collections project.

First of all enable software collections repo:

sudo yum install centos-release-scl

Now you can install gcc-6.x, gcc-7.x etc. with proper parameter like below:

sudo yum install devtoolset-6-gcc*

This method brings newer versions without uninstalling or overwriting existing ones. For this reason, you have to enable devtoolset in current shell before using gcc:

scl enable devtoolset-6 bash

And check the gcc version:

$ gcc -v
gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC)