Monday | 15 APR 2024
[ previous ]
[ next ]

Using a Newer GCC in RHEL 7

Date: 2022-03-19

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

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)
  • source -