Using a Newer GCC in RHEL 7


Red hat linux comes with gcc 4.8 and this seems to be a system requirement and so you can’t upgrade it. The way to use newer versions of gcc then is to do something similar to how nvm manages node. We can install devtoolsets and use software collections to manage the gcc.

The first step is to install the software collections repo.

# rpm -i http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-rh-2-3.el7.centos.noarch.rpm

Now that we have the repo, we can install devtoolset-10.

# yum install devtoolset-10

Now you can set up your environment to use the newer gcc by sourcing it.

# source scl_source enable devtoolset-2

Voila! We now should be able to do gcc -v and see the newer version.

> gcc -v
gcc version 10.2.1 20210130 (Red Hat 10.2.1-11) (GCC)