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.

Answer from Florian Weimer on Stack Overflow
๐ŸŒ
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 - $ gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-16) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ... To compile foo.c into foo executable file, type: $ cc foo.c -o foo To execute foo program, type: $ ./foo Outputs: Hello World! Use the yum command as follows: ##[ CentOS 7 ] ## $ sudo yum install man-pages man-db man ##[ CentOS 6.x ] ## $ sudo yum install man man-pages
๐ŸŒ
JWillikers
jwillikers.com โ€บ build-gcc-from-source-on-centos-7
Build GCC From Source on CentOS 7 - JWillikers
October 28, 2020 - Shell commands are provided in both Bash, the native shell on CentOS 7, and fish because it has standards. If you arenโ€™t using the DNF package manager yet, grab that. ... Install the dependencies necessary to build GCC.
๐ŸŒ
Bits and Dragons
bitsanddragons.wordpress.com โ€บ 2024 โ€บ 04 โ€บ 15 โ€บ howto-install-and-compile-gcc-on-centos-8-stream
HOWTO: install and compile gcc on CentOS 8 stream. | Bits and Dragons
April 17, 2024 - I'm going to be following this guide. But on CentOS 8 stream. You can skip reading if you don't work on IT, because today I don't find myself specially funny. So this is going to be just technical. We wget gcc-9, and untar it in the chosen location (software) software]# wget https://ftp.gnu.org/gnu/gcc/gcc-9.1.0/gcc-9.1.0.tar.gzsoftware]# tar -xvzf gcc-9.1.0.tar.gzโ€ฆ
Find elsewhere
๐ŸŒ
Linuxize
linuxize.com โ€บ home โ€บ gcc โ€บ how to install gcc compiler on centos 7
How to Install GCC Compiler on CentOS 7 | Linuxize
October 31, 2019 - Weโ€™ll explain how to install the distro stable version and the newer version of GCC available from the SCL repository. To add new repositories and install packages on your CentOS system, you must be logged in as root or user with sudo privileges .
๐ŸŒ
Stack Exchange
unix.stackexchange.com โ€บ questions โ€บ 588121 โ€บ how-to-install-gcc-without-yum-on-centos-7
python - How to install GCC without yum on CentOS 7? - Unix & Linux Stack Exchange
And when I search how to install GCC without yum, most of them need yum! Is there really a way to solve this problem? ... You can fix this with the rpm command. Could you update your question with the output of rpm -V python, which verifies the python package. ... Firstly , CentOS bundled with python i guess , so just check where python ( which python )is located and create a link for /usr/bin/python2.7
๐ŸŒ
Centos
lists.centos.org โ€บ hyperkitty โ€บ list โ€บ discuss@lists.centos.org โ€บ thread โ€บ POTHJYRWJSSESJ3TWDHO76JIMAXZBYCS
Package of GCC 12 on CentOS 7 - Discuss - lists.centos.org
Is there an rpm of GCC 12 (or at least higher than 9) available to download and install, or is it a case of downloading and build from the source yourself?
๐ŸŒ
VietHosting
viethosting.com โ€บ home โ€บ tutorials โ€บ servers โ€บ how to install g++ (gcc c++) on centos via command line
How to Install g++ (GCC C++) on CentOS via Command Line
April 8, 2026 - To install the g++ compiler on ... sudo dnf group install "Development Tools" 2. Or install just the C++ compiler: sudo dnf install gcc-c++ Once installed, verify the version by running: g++ --version...
๐ŸŒ
LinuxHostSupport
linuxhostsupport.com โ€บ home โ€บ how to install gcc on centos 7
How To Install GCC on CentOS 7 | LinuxHostSupport
May 24, 2019 - Run the following command to install GCC on your server ... gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. As might be seen from the output, the GCC version distributed by CentOS 7 is 4.8.5 which is not the latest version of GCC.
๐ŸŒ
Snapcraft
snapcraft.io โ€บ install โ€บ gcc-13 โ€บ centos
Install gcc-13 on CentOS using the Snap Store | Snapcraft
May 26, 2025 - Get the latest version of gcc-13 for on CentOS - the GNU Compiler Collection version 13.
๐ŸŒ
The Linux Cluster
thelinuxcluster.com โ€บ 2022 โ€บ 07 โ€บ 01 โ€บ compiling-gcc-10-4-0-on-centos-7
Compiling GCC-10.4.0 on CentOS-7 โ€“ The Linux Cluster
July 1, 2022 - Step 1: Download the TarBall version of GCC version. If you want to take look at all the available versions, you can take a look at http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/ For this blog entry, we will install GCC-10.4.0. ...
๐ŸŒ
Linux Questions
linuxquestions.org โ€บ questions โ€บ linux-software-2 โ€บ i-should-install-gcc-4-1-2-to-centos-7-0-a-4175521263
I should install gcc-4.1.2 to Centos 7.0
Hi, I should install very old gcc 4.1.2 with the standard gcc builder of Centos 7.0. Please let me know what is the best way to do this... 1. Should I
๐ŸŒ
Reddit
reddit.com โ€บ r/linuxquestions โ€บ beginner with centos. what is best way to upgrade gcc?
r/linuxquestions on Reddit: Beginner with Centos. What is best way to upgrade GCC?
October 28, 2022 -

Edit: What happened? When I went to download centos I mistakenly understood centos 7 as being the most recent stable version. Original post below:

Ok, I have only used the mint distro as of yet (for about a year now). I wanted to start getting to know other distros so I repaired an older funky pc's power supply and changed out the windows 7 on it for Centos with Gnome desktop just yesterday. So Centos is new to me and mint has been my experience (but I am still a novice with it).

I checked out the GCC and it's version 4.8.5 . On my mint laptop I was able to install version 10.3.0 through the apt package manager. The search results I get from using yum though do not seem to spit out anything similar as far as I can tell. And the google searches I do seem to all point towards installing from source.

But a friend of mine the other day when discussing how I used my laptop in mint was very emphatic that I should avoid as much as possible installing anything from source that was available already through a package manager, saying that when things later become updated it is much safer and less of a mess to have the package manager handle the changes.

So my noob question is this... Does that type of thinking not apply to the Centos distro? Or is the purpose of Centos less intended for developers? Or something else?

In the end I am too ignorant in this current situation to really know what I am ignorant of so bottom line question is:

In Centos 7 What is the most recommended way to upgrade GCC?

Thanks

Top answer
1 of 6
6
Centos 7 The latest stable release is 8 and I think Stream is on 9, is there a reason you're using a decade-old release? You could try installing distrobox (or toolbox) and set up a Fedora container for your compiler. This way it won't conflict with anything and you avoid dependency hell. You'll still need to upgrade to 8 at least though, since 7 only ships an old version of podman that probably doesn't even support rootless containers.
2 of 6
2
Why are you using CentOS 7, it was release on July 7, 2014? I currently don't know what GCC version CentOS 8 (stream) has, but CentOS 9 stream has 11.3.1-2 currently. I guess until CentOS 7 EOL there won't be any big GCC version updates, as CentOS is a stable distribution, compared to mint which gets bigger version updates way more often. CentOS (was) downstream from RHEL, which is intended to run on professional servers for years on end. Thus, it "only" gets security updates, but no big / breaking version bumps. For servers, stability is key, once they're set up, they are supposed to run until the OS goes EOL (or the server is faded out), in this case 10 years. Mint is based on Ubuntu which is also mostly stable, but every spring and fall there is a new version (Ubuntu 21.10 (fall 2021), Ubuntu 22.04(spring 2022), Ubuntu 22.10(fall 2022), etc.) thus mint is at most on a half year old GCC version. On the other end of the spectrum there are distros like arch and openSUSE Tumbleweed which are so-called "rolling releases". They only have one version, the current one. And Packages are always kept up to date, as soon as the developers release a new one. Should you compile a new GCC version? Probably not, too much potential for things to break, except you want to learn about how Linux works... Like this Guy: https://reddit.com/r/linux/comments/ye9h57/latest_gentoo_release_running_an_11_year_old/
๐ŸŒ
Psychz
psychz.net โ€บ client โ€บ kb โ€บ en โ€บ how-to-install-the-gcc-compiler-in-centos-7.html
How to install the GCC compiler in CentOS 7? ...
March 17, 2019 - Run the following command to install GCC on your server ... Running transaction test Transaction test succeeded Running transaction Installing : cpp-4.8.5-36.el7.x86_64 1/5 Installing : kernel-headers-3.10.0-957.5.1.el7.x86_64 2/5 Installing : glibc-headers-2.17-260.el7_6.3.x86_64 3/5 Installing : glibc-devel-2.17-260.el7_6.3.x86_64 4/5 Installing : gcc-4.8.5-36.el7.x86_64 5/5 Verifying : glibc-devel-2.17-260.el7_6.3.x86_64 1/5 Verifying : gcc-4.8.5-36.el7.x86_64 2/5 Verifying : kernel-headers-3.10.0-957.5.1.el7.x86_64 3/5 Verifying : cpp-4.8.5-36.el7.x86_64 4/5 Verifying : glibc-headers-2.17-260.el7_6.3.x86_64 5/5 Installed: gcc.x86_64 0:4.8.5-36.el7
Call ย  800-933-1517
Address ย  611 Wilshire Blvd #300, 90017, Los Angeles,
๐ŸŒ
cPanel
support.cpanel.net โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 19161804558103-How-to-update-default-GCC-on-a-CentOS-7-9
How to update default GCC on a CentOS 7.9? โ€“ cPanel
On a CentOS 7 test machine, I also see version 4.8.5. It seems that this is a common question as I see a similar question posted here: ... Hi @cPRex Since this morning I haven't been idle, I tried to update and it seems to be a success To start, I remove what I installed by mistake: yum remove devtoolset-9-* Then I : 949 2022-03-14 12:17:50 wget https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz 950 2022-03-14 12:20:03 tar -xvf gcc-9.2.0.tar.gz 951 2022-03-14 12:20:20 cd gcc-9.2.0 952 2022-03-14 12:20:27 ./configure 953 2022-03-14 12:21:51 sudo yum install glibc-devel.i686 954 2022-03-14 1