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
Discussions

c++ - Install older gcc/g++ versions in CentOS 8 - Stack Overflow
I've been struggling with this for the past 2h. In CentOS 8 I can't find the devtoolset packages to install older gcc/g++ versions. There is no longer a scl repo for CentOS 8. I need gcc/g++ 4.9x More on stackoverflow.com
๐ŸŒ stackoverflow.com
linux - Installing older package of gcc on Centos 8 via dnf - Unix & Linux Stack Exchange
I am new to centos 8 and want to install gcc 6.3.1 on Centos 8 via dnf but it looks like Centos 8 comes with gcc 8.* and no previous version is present in the mirror so downgrading is not working. Is More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
c++ - Compile old gcc version on Centos 8 - Stack Overflow
I'm struggling compiling an old GCC version on Centos 8. Basic development tools come with GCC 8.5, but I would need to get GCC 5.3. I've tried the following: yum install glibc.i686 ncurses-libs.i686 More on stackoverflow.com
๐ŸŒ stackoverflow.com
c++ - How to install gcc/g++ 9 on CentOS 8 docker (centos:latest) - Stack Overflow
In order to use the C++17 include I need gcc-9 package in my centos docker. By default centos:latest (aka 8) will install gcc 8.3.1 from the regular distro repo. Is there any P... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Medium
bipulkkuri.medium.com โ€บ upgrade-gcc-from-source-on-centos-8-linux-release-55d17ff8e5bb
Upgrade GCC from source on Centos 8 Linux release | by Bipul Kuri | Medium
August 18, 2020 - Upgrade GCC from source on Centos 8 Linux release Lets upgrade gcc in centos 8 from source,We upgraded to gcc 9.2.0 Install latest GCC on Centos Linux release 7.6 When you have to upgrade gcc to โ€ฆ
๐ŸŒ
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 (development tools) on centos 8
How to Install GCC (Development Tools) on CentOS 8 | Linuxize
March 9, 2020 - Validate that the GCC compiler is successfully installed by using the gcc --version command which prints the GCC version: ... gcc (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4) Copyright (C) 2018 Free Software Foundation, Inc.
๐ŸŒ
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 - gcc --version gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10) Copyright (C) 2018 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 ...
๐ŸŒ
Server Fault
serverfault.com โ€บ questions โ€บ 1114217 โ€บ how-to-safely-downgrade-gcc-from-8-5-to-8-4
centos - How to safely downgrade gcc from 8.5 to 8.4? - Server Fault
After I downgrade a couple of times, ... gcc-plugin-annobin-8.5.0-13.el8.x86_64 - package gcc-plugin-annobin-8.5.0-13.el8.x86_64 requires gcc = 8.5.0-13.el8, but none of the providers can be installed etc etc ......
๐ŸŒ
Linux Hint
linuxhint.com โ€บ install-gcc-compiler-centos-8
How to Install GCC Compiler on CentOS 8 โ€“ Linux Hint
To do that, run the โ€œgcc โ€“versionโ€ command on the terminal: ... As you can see, the GCC Compiler has been successfully installed on the CentOS 8 operating system.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 72026286 โ€บ compile-old-gcc-version-on-centos-8
c++ - Compile old gcc version on Centos 8 - Stack Overflow
I'm struggling compiling an old GCC version on Centos 8. Basic development tools come with GCC 8.5, but I would need to get GCC 5.3. I've tried the following: yum install glibc.i686 ncurses-libs.i686
๐ŸŒ
VITUX
vitux.com โ€บ gcc-compiler-centos
How to Install GCC Compiler Collection on CentOS 8 and Rocky Linux 8 โ€“ VITUX
October 21, 2021 - This article will show you how to install the GCC compiler on centos 8. It is important for developers who want to write C/C++ programs for Linux operating systems.
๐ŸŒ
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/
๐ŸŒ
Linux Hint
linuxhint.com โ€บ install_gcc_build_tools_centos8
Installing GCC and C/C++ Build Tools on CentOS 8 โ€“ Linux Hint
In this article, I am going to show you how to install GCC and all the required C/C++ build tools on CentOS 8 for developing C/C++ programs.
๐ŸŒ
Dotlinux
dotlinux.net โ€บ blog โ€บ how-to-install-gcc-the-c-compiler-on-rhel-8-centos-8
How to Install GCC (the C Compiler) on RHEL 8 / CentOS 8
RHEL 8 and CentOS 8 use the AppStream repository to distribute applications and tools, including GCC. AppStream uses "modules" to manage different versions of software, allowing you to install specific versions (e.g., GCC 8, 9, or 10) if needed.
๐ŸŒ
Red Hat
access.redhat.com โ€บ solutions โ€บ 19458
What GCC versions are available in Red Hat Enterprise Linux? - Red Hat Customer Portal
What GCC versions are available in Red Hat Enterprise Linux? What C and C++ compiler comes with RHEL, GCC Toolset, Developer Toolset? Are the GCC Toolset and Developer Toolset available for my RHEL version?