🌐
GitHub
gist.github.com › nchaigne › ad06bc867f911a3c0d32939f1e930a11
Building GCC 9.2.0 on CentOS 7 · GitHub
This note describes how to build the latest GCC (9.2.0 as of October 2019) from sources on CentOS 7. This should be applicable as is on RHEL 7. For other Linux distributions, adapt as needed. While this is not overly complicated, building GCC takes quite some time. So you might want to plan to do something else while it builds... a coffee break just won't make it. Prerequisites are described here: https://gcc.gnu.org/install/prerequisites.html
🌐
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.
🌐
JWillikers
jwillikers.com › build-gcc-from-source-on-centos-7
Build GCC From Source on CentOS 7 - JWillikers
October 28, 2020 - This tutorial provides the steps necessary to compile and install a newer version of GCC, version 10.2.0 to be specific, on CentOS 7. The GCC front-ends for C, C++, and Fortran are included. You should be familiar with command-line tools, CentOS, and the compiling and installing software on Linux.
🌐
Centos
cbs.centos.org › koji › buildinfo
devtoolset-11-gcc-11.2.1-1.1.el7 | Build Info | CentOS Community Build Service
October 19, 2021 - Main Site Links: · Summary · Packages · Builds · Tasks · Build Targets · Users · Hosts · Reports · Search
🌐
Medium
bipulkkuri.medium.com › install-latest-gcc-on-centos-linux-release-7-6-a704a11d943d
Install latest GCC on Centos Linux release 7.6
August 18, 2020 - ... And all scripts together. sudo ... ../gcc-8.2.0/configure --enable-languages=c,c++ --disable-multilib make -j$(nproc) sudo make install gcc --version...
🌐
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.
🌐
CyberITHub
cyberithub.com › install-gcc-and-c-compiler
Easy Steps to Install GCC(C and C++ Compiler) on CentOS 7 | CyberITHub
January 18, 2020 - Download from Repository and install gcc tool using yum install gcc command.
Find elsewhere
🌐
Stack Exchange
unix.stackexchange.com › questions › 698886 › gcc-11-installation-error-in-centos-7-environmental-changes
linux - GCC-11 installation error in centos 7 (environmental changes)? - Unix & Linux Stack Exchange
April 12, 2022 - Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I installed the latest version of GCC 11.2V using conda, conda install -c conda-forge gcc" in my linux server (Centos7).
Top answer
1 of 2
16

I've confirmed that you can upgrade gcc from the default version 4.8 on centOS 7.

First, we need to install "Software Collections" in order to access some of the community packages including gcc v7

  • sudo yum install -y centos-release-scl

Next, we want to install a developer toolset. Depending on your needs, you may want a different devtoolset. Here I'm targeting 7:

  • sudo yum install -y devtoolset-7

Finally, you'll want to change over to gcc 7 as your default, launch a new shell session with the scl tool:

  • scl enable devtoolset-7 bash
2 of 2
1

Enable the software collection in the answer is only effective in the current shell. The scl utility will create a "child-shell" that set the PATH variables properly, so that in the new child-shell, the enabled software collections will be firstly searched. These settings obviously only take effective temporarily in the current shell.

To make it permanently effective, add the command, source /opt/rh/devtoolset-7/enable to the user's profile (~/.bash_profile or ~/.bashrc for RHEL based OS, like CentOS 7). Then, start a new shell and you will have the right tools available.

After execute scl enable devtoolset-7 bash, you will need to execute exit twice to exit the opened shell window, which verifies that the scl command created a new shell instance as a child process. There might be side-effect with creating a child-shell, so do not put this command in the ~/.bashrc profile, otherwise it will repeatedly create child-shell (non-login shell) as each shell will load the profile, resulting in a endless recursive loop. Put it in ~/.bash_profile, it will be loaded for only once (for the login shell), but you will need to exit twice every time.

But for development purpose, scl enable devtoolset-7 bash would be preferred, as you can exit the created child-shell, and then switch between different versions of the same software.


More details about the GCC version in python terminal:

The version info of the built-in Python in CentOS 7:

[root@conda condabuilder]# python
Python 2.7.5 (default, Nov 16 2020, 22:23:17) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

The version info of the user installed (via conda) Python on a system even without higher version of GCC installed:

[root@conda condabuilder]# conda activate jupyter
(jupyter) [root@conda condabuilder]# python -VV
Python 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:20:04) [GCC 11.3.0]

From the results, we can see that the GCC version contained in Python's version info is not related to the system's GCC. The system's default Python (2.7.5) should have been compiled with the GCC version distributed with CentOS 7, so the version info show the same GCC version. But for user installed python, the GCC version info actually depends on what version of GCC is used for building and packging the python binary.

🌐
Ahelpme
ahelpme.com › home › linux › centos 7 › how to install new gcc and development tools under centos 7
How to install new gcc and development tools under CentOS 7 | Any IT here? Help Me!
September 5, 2019 - [srv@local ~]# yum install ...====================================================== Installing: devtoolset-7-gcc x86_64 7.3.1-5.4.el7 centos-sclo-rh 29 M devtoolset-7-gcc-c++ x86_64 7.3.1-5.4.el7 centos-sclo-rh 11 M devtoolset-7-gcc-gdb-plugin x86_64 7.3.1-5.4.el7 ...
🌐
jdhao's digital space
jdhao.github.io › 2017 › 09 › 04 › install-gcc-newer-version-on-centos
How to Compile and Install Latest Version of GCC on CentOS 7 · jdhao's digital space
April 20, 2019 - The default GCC that comes with the CentOS 7.2 is GCC 4.8.5, which does not support the complete C++11 standard, for example, it does not fully support regular expressions. In order to use regular expression functions, we need to install at least GCC 4.9.0. The following installation procedure ...
🌐
Centos
lists.centos.org › hyperkitty › list › discuss@lists.centos.org › message › OLWN2OCWBQCNC3ZB2WVCVAM7TQT7RQ6A
Re: [CentOS] Package of GCC 12 on CentOS 7 - Discuss - lists.centos.org
Is there an rpm of GCC 12 (or at ... That's what Software Collections is for. ... Specifically you need one of the devtoolset collections - it goes up to 11 which, unsurprisingly, provides gcc-11 on CentOS 7....
🌐
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/
🌐
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 - The default CentOS repositories contain a package group named “Development Tools” that includes the GNU compiler collection, GNU debugger, and other development libraries and tools required for compiling software. To install the Development Tools packages, run the following command as root or user with sudo privileges : ... The command installs a lot of packages, including gcc, g++ and make.
🌐
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 - Note: You need to log in to your CentOS 7 VPS via SSH as user root ... GCC can be easily installed from the official CentOS repositories. Run the following command to install GCC on your server
Call   800-933-1517
Address   611 Wilshire Blvd #300, 90017, Los Angeles,
🌐
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 CentOS, AlmaLinux, or Rocky Linux, use one of the following commands: 1. Install the full build environment (Recommended): sudo dnf group install "Development Tools" 2. Or install just the C++ compiler: sudo dnf ...