yum install centos-release-scl-rh
yum install devtoolset-3-gcc devtoolset-3-gcc-c++
update-alternatives --install /usr/bin/gcc-4.9 gcc-4.9 /opt/rh/devtoolset-3/root/usr/bin/gcc 10
update-alternatives --install /usr/bin/g++-4.9 g++-4.9 /opt/rh/devtoolset-3/root/usr/bin/g++ 10
Answer from Lars Bilke on Stack Overflow
🌐
Red Hat
developers.redhat.com › blog › 2019 › 03 › 05 › yum-install-gcc-8-clang-6
How to install GCC 8 and Clang/LLVM 6 on Red Hat Enterprise Linux 7 | Red Hat Developer
November 1, 2023 - Under your normal user ID, run scl enable to add devtoolset-8 and llvm-toolset-6.0 to your path(s). Optional: Permanently enable GCC 8 and Clang 6 by adding scl_source to your .bashrc.
🌐
Red Hat
developers.redhat.com › HW › gcc-RHEL-7
Hello World - installing GCC on RHEL 7 | Red Hat Developer
April 13, 2026 - In this next step you will use a single command to download and install GCC 8.2, and other development tools that are part of Red Hat Developer Toolset. The length of time this step takes depends on the speed of your Internet connection and your system.
Discussions

linux - how to install gcc 4.9.2 on RHEL 7.4 - Stack Overflow
I am trying to install gcc and g++ 4.9.2 on Linux. I'm pretty new with Linux and i saw some guides of how to install, but each time I encountered with another problem. I don't have any gcc right no... More on stackoverflow.com
🌐 stackoverflow.com
How to install GCC/G++ 8 on CentOS - Stack Overflow
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 t... More on stackoverflow.com
🌐 stackoverflow.com
rhel - How to install gcc 9.X on RHEL8? - Unix & Linux Stack Exchange
I see from the documentation here that gcc has been updated on RHEL8, but what I haven't figured out is how to get it. The documentation indicates that there are now two streams, but I already hav... More on unix.stackexchange.com
🌐 unix.stackexchange.com
May 7, 2020
software installation - install latest gcc on rhel 6 x86_64 - Unix & Linux Stack Exchange
I have an RHEL 6 server with gcc version 4.4.7. I wanted to update the gcc version (I think the current one is 4.8). Yum update doesn't work. Also, SO answers for a similar question on CentOS does ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
April 20, 2014
🌐
LinuxConfig
linuxconfig.org › home › how to install gcc the c compiler on rhel 8 / centos 8
How to install GCC the C compiler on RHEL 8 / CentOS 8
September 24, 2019 - The GCC compiler can be installed in RHEL 8 by simply using the dnf install command.
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_enterprise_linux › 8 › html › developing_c_and_cpp_applications_in_rhel_8 › additional-toolsets-for-development_developing-applications
Chapter 4. Additional toolsets for development | Developing C and C++ applications in RHEL 8 | Red Hat Enterprise Linux | 8 | Red Hat Documentation
Replace package_name with a space-separated list of packages to install. For example, to install the gcc-toolset-13-annobin-annocheck and gcc-toolset-13-binutils-devel packages: # yum install gcc-toolset-13-annobin-annocheck gcc-toolset-13-binutils-devel
🌐
nixCraft
cyberciti.biz › nixcraft › howto › centos › centos / rhel 7: install gcc (c and c++ compiler) and development tools
CentOS / RHEL 7: Install GCC (C and C++ Compiler) and Development Tools - nixCraft
April 5, 2024 - To install all the packages belonging to a package group called “Development Tools” use the following command: # yum --setopt=group_package_types=mandatory,default,optional groupinstall "Development Tools" OR # yum --setopt=group_package_types=mandatory,default,optional group install "Development Tools" The yum has changed in Red Hat Enterprise Linux 7/CentOS 7. The package group “Development Tools”” has only the optional packages which by default doesn’t get installed. So we will need to pass the option --setopt=group_package_types=mandatory,default,optional to install the optional packages too. Type the following which command or type command/command command to see the gcc binary location.
Top answer
1 of 4
22
yum install centos-release-scl-rh
yum install devtoolset-3-gcc devtoolset-3-gcc-c++
update-alternatives --install /usr/bin/gcc-4.9 gcc-4.9 /opt/rh/devtoolset-3/root/usr/bin/gcc 10
update-alternatives --install /usr/bin/g++-4.9 g++-4.9 /opt/rh/devtoolset-3/root/usr/bin/g++ 10
2 of 4
21

For installing the system compilers gcc, g++, the install command is # yum install gcc-c++ → Provides version 4.8.5 : /usr/bin/{ gcc, g++ }.

Other options: 1. gcc53-c++-5.3.0-1.el6.x86_64.rpm → https://drive.google.com/file/d/0B7S255p3kFXNRm9FVnZYUnhyZzg/view?usp=sharing&resourcekey=0-1N6zQa6Sbl_WycG1O9I7JA : Download and install : # cd Downloads/ && yum install ./gcc53-c++-5.3.0-1.el6.x86_64.rpm ..... Provides /usr/bin/{gcc53, g++53}.

  1. The devtoolset´s : https://www.softwarecollections.org/en/scls/rhscl/devtoolset-6/ → # yum-config-manager --enable rhel-server-rhscl-7-rpms

Install gcc, g++ version 4.9.2 : # yum install devtoolset-3-gcc-c++

Note : You can have as many gcc/g++ versions as you want, installed at the same time. ( The system compilers are a must.)


  1. gcc49-c++-4.9.3-1.el6.x86_64.rpm https://drive.google.com/file/d/1Pwq1ua80dGM72i7rpDNAIIdfcR1WK-hG/view?usp=sharing → Provides /usr/bin/{gcc49, g++49}.

  1. gcc63-c++-6.3.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1t4WrgvpEP-6_NN3qMJhz9MS3CJhHrHKc/view?usp=sharing → Provides /usr/bin/{gcc63, g++63}.

  2. gcc45-c++-4.5.4-1.el7.x86_64.rpm https://drive.google.com/file/d/15aRg-BPhuyaEyZA9Jy-iAyC21_pwN7nD/view?usp=sharing → Provides /usr/bin/{gcc45, g++45, gfortran45}

  3. gcc42-c++-4.2.4-1.el6.x86_64.rpm https://drive.google.com/file/d/1eYWk6Nd63xeqqAUoJldNWRuwEGO6cAyv/view?usp=sharing → Provides /usr/bin/{gcc42, g++42}


  1. gcc73-c++-7.3.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1PgwCP5tu8D0EJbJVTqJd7Vg8dJ4l4noi/view?usp=sharing → Provides /usr/bin/{gcc73, g++73}

  2. gcc48-c++-4.8.5-1.el6.x86_64.rpm https://drive.google.com/file/d/1w6fW6oSflDDYZt_cOpGj3QMEmzUC8Q9L/view?usp=sharing → Provides /usr/bin/{gcc48, g++48, gfortran48}

  3. gcc84-c++-8.4.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1xgFtsiDi2uiB1B0AcOaSpxVizzET-pJf/view?usp=sharing → Provides /usr/bin/{gcc84, g++84, gfortran84}

🌐
Red Hat
developers.redhat.com › blog › 2018 › 11 › 13 › gcc-8-2-ga-rhel
GCC 8.2 now GA for Red Hat Enterprise Linux | Red Hat Developer
March 24, 2023 - We are pleased to announce general availability of Red Hat Developer Toolset 8 for Red Hat Enterprise Linux 6 and 7. The key new components for this release are: ... See the "New Features" section below for more details. Like other tools, these are easily installable via yum, see How to install GCC 8 on Red Hat Enterprise Linux.
Find elsewhere
🌐
ComputingForGeeks
computingforgeeks.com › home › install gcc and development tools on rhel 8 / centos 8
Install GCC and Development Tools on RHEL 8 / CentOS 8 [Guide]
August 17, 2023 - Step-by-step guide to gCC and Development Tools on RHEL 8 / CentOS 8. Includes commands, verification, and troubleshooting.
🌐
TecMint
tecmint.com › home › open source › how to install gcc and development tools on rhel-based systems
How to Install GCC and Development Tools on RHEL Systems
August 13, 2024 - If gcc and/or g++ and its related Development Tools are not installed in your system by default, you can install the latest available from the repositories as follows: yum groupinstall 'Development Tools' OR dnf groupinstall 'Development Tools'
🌐
Medium
medium.com › @ihouelecaurcy › how-to-check-and-install-gcc-on-linux-complete-developer-guide-98697e2ab78f
How to Check and Install GCC on Linux: Complete Developer Guide | by Ihouele Caurcy | Medium
July 24, 2025 - sudo yum install gcc # Or install complete development tools sudo yum groupinstall "Development Tools" Fedora: sudo dnf install gcc # Or install complete development tools sudo dnf groupinstall "Development Tools" # Install GCC sudo pacman -S ...
🌐
Red Hat
developers.redhat.com › blog › 2018 › 07 › 07 › yum-install-gcc7-clang
How to install Clang/LLVM 5 and GCC 7 on RHEL | Red Hat Developer
November 1, 2023 - Optional: Permanently enable GCC 7 and Clang 5 by adding scl_source to your .bashrc · $ su - # subscription-manager repos --enable rhel-7-server-optional-rpms \ --enable rhel-server-rhscl-7-rpms \ --enable rhel-7-server-devtools-rpms # cd /etc/pki/rpm-gpg # wget -O RPM-GPG-KEY-redhat-devel https://www.redhat.com/security/data/a5787476.txt # rpm --import RPM-GPG-KEY-redhat-devel # yum install devtoolset-7 llvm-toolset-7 # yum install llvm-toolset-7-clang-analyzer llvm-toolset-7-clang-tools-extra # optional # exit $ scl enable devtoolset-7 llvm-toolset-7 bash $ gcc --version gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5) $ clang --version clang version 5.0.1 (tags/RELEASE_501/final) $ # Optionally permanently enable GCC 7 / Clang 5 $ echo "source scl_source enable devtoolset-7 llvm-toolset-7" >> ~/.bashrc
Top answer
1 of 2
8

Red Hat Enterprise Linux, being an "enterprise" operating system, is designed to be stable and similar for a long time. That means you do not get the "latest and greatest" by default, but a known-good implementation that remains the default on that particular RHEL version for the long term. Generally you only get substantial software upgrades by upgrading RHEL. Unfortunately, there is no RHEL 8 yet.

devtoolset allows you to switch to newer, out-of-band versions of development software like GCC, in a way that doesn't "contaminate" the whole OS installation. I used it, with great success, to get GCC 4.8 (and its C++11 support) on CentOS 6, where the official GCC is 4.4.

devtoolset-8 has GCC 8.2.1.

Or you could choose to use a distribution more suited for home users, such as Fedora.

Or you could download the GCC source and build it yourself (but ew!).

2 of 2
4

One can surely build the gcc on CentOS oneself(though ew!).

Generally follow the below steps:

sudo yum -y update
sudo yum -y install bzip2 wget gcc gcc-c++ gmp-devel mpfr-devel libmpc-devel make
gcc --version
wget http://mirrors-usa.go-parts.com/gcc/releases/gcc-8.2.0/gcc-8.2.0.tar.gz
tar zxf gcc-8.2.0.tar.gz
mkdir gcc-8.2.0-build
cd gcc-8.2.0-build
../gcc-8.2.0/configure --enable-languages=c,c++ --disable-multilib
make -j 2
sudo make install
gcc --version

At this point, many can not see 8.2, i.e.

gcc version 4.8.5 (GCC)

Just overwrite the old gcc with which just built, i.e.

# which gcc
/usr/local/bin/gcc
# cp gcc/xgcc /usr/local/bin/gcc
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/aarch64-unknown-linux-gnu/7.2.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: ../gcc-7.2.0/configure --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 7.2.0 (GCC)

In order to avoid library error, one may need update libstdc as well,

cp ./aarch64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6 /usr/local/lib64/libstdc++.so.6
cp ./stage1-aarch64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6 /usr/lib64/libstdc++.so.6

One may also update libc.so as well, i.e. 2.18

curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
tar zxf glibc-2.18.tar.gz
cd glibc-2.18/
mkdir build
cd build/
../configure --prefix=/usr
make -j2
make install
ln -sf /usr/glibc-2.18/glibc-2.18.so /lib64/libc.so.6

Finally, type /lib64/libc.so.6 to confirm

Mostly, ln would fail, since old relations, and LD is suggested, i.e.

LD_LIBRARY_PATH=/usr/glibc-2.18/lib
export LD_LIBRARY_PATH
🌐
Red Hat
developers.redhat.com › articles › build-your-first-app-native-gcc-rhel-6-or-7
Build your first app with native GCC on RHEL 6 or 7 | Red Hat Developer
January 2, 2024 - Now download and install any available updates by running yum update. If updates are available, yum will list them and ask if it is OK to proceed. ... In this next step you will use a single command to download and install the GCC C and C++ ...
🌐
GitHub
gist.github.com › stephenturner › e3bc5cfacc2dc67eca8b
Installing gcc 4.8 and Linuxbrew on CentOS 6 · GitHub
$ cat /etc/centos-release CentOS release 6.7 (Final) $ sudo yum install centos-release-scl $ sudo yum install devtoolset-3-toolchain $ scl enable devtoolset-3 bash $ gcc --version gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6) ... $ g++ --version ...