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
Answer from nulltron on Stack Exchange
🌐
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 centos-sclo-rh 123 k devtoolset-7-gcc-gfortran ...
🌐
GitHub
github.com › nealef › clefos › issues › 9
yum -y install devtoolset-11-* failing with `No package devtoolset-11-* available.` · Issue #9 · nealef/clefos
January 29, 2022 - It seems that devtoolset-11 has not been rebuild yet for clefos 7. Is this planned and if so, do you have an ETA on this ? This has been found when investigating pypa/manylinux#1266 CentOS 7 sources are available for devtoolset-11: https://vault.centos.org/centos/7/sclo/Source/rh/ The CentOS 7 x86_64 image is able to run the same commands as below successfully.
Author   nealef
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.

🌐
CERN
linuxsoft.cern.ch › cern › centos › 7 › sclo › x86_64 › rh › repoview › devtoolset-11-gdb.html
devtoolset-11-gdb
CentOS 7 - SCL for x86_64: unspecified: devtoolset-11-gdb · Jump to letter: [ CDGHLMNPRSTV ]
🌐
Centos
buildlogs.centos.org › centos › 7 › sclo › x86_64 › rh › Packages › d
Index of /centos/7/sclo/x86_64/rh/Packages/d
This server contains a mix of raw/unsigned packages and/or build logs It should be used mainly for testing purposes
🌐
GitHub
github.com › pypa › manylinux › issues › 1266
devtoolset-11 for manylinux_2014 · Issue #1266 · pypa/manylinux
January 27, 2022 - Last year we had the upgrade to devtoolset-10 for manylinux_2014 see #1141 and #1155. Now the devtoolset-11 is also released for CentOS 7. See below: https://centos.pkgs.org/7/centos-sclo-rh-x86_64/devtoolset-11-toolchain-11.0-3.el7.x86_...
Author   pypa
🌐
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
🌐
Stack Overflow
stackoverflow.com › questions › tagged › devtoolset
Newest 'devtoolset' Questions - Stack Overflow
I'm facing a strange error ("reference to 'list' is ambiguous") in compiling a C++ 3rd party software under CentOS 7 with devtoolset-11.
Find elsewhere
🌐
CERN
linuxsoft.cern.ch › cern › centos › 7 › sclo › x86_64 › rh › repoview › devtoolset-11-libstdc++-devel.html
devtoolset-11-libstdc++-devel
CentOS 7 - SCL for x86_64: unspecified: devtoolset-11-libstdc++-devel · Jump to letter: [ CDGHLMNPRSTV ]
🌐
Centos
buildlogs.centos.org › c7-devtoolset-7.aarch64 › Packages
Index of /c7-devtoolset-7.aarch64/Packages
This server contains a mix of raw/unsigned packages and/or build logs It should be used mainly for testing purposes
🌐
Fedora Discussion
discussion.fedoraproject.org › team workflows › projects in copr
mayeut/devtoolset-11 - Fedora Discussion
January 29, 2022 - Description devtoolset-11 rebuild for centos 7 i686 Installation Instructions yum install devtoolset-11-binutils devtoolset-11-gcc [...] Active Releases The following unofficial repositories are provided as-is by owner of this project. Contact the owner directly for bugs or issues (IE: not bugzilla).
🌐
Utah
mirror.chpc.utah.edu › pub › centos › 7 › sclo › x86_64 › rh › Packages › d
https://mirror.chpc.utah.edu/pub/centos/7/sclo/x86...
Parent Directory - devtoolset-7-7.0-5.el7.x86_64.rpm 2020-03-23 02:24 5.5K devtoolset-7-7.0-8.el7.sc1.x86_64.rpm 2020-03-12 10:30 5.8K devtoolset-7-7.0-8.el7.x86_64.rpm 2020-03-23 02:25 5.8K devtoolset-7-7.1-4.el7.x86_64.rpm 2020-03-12 10:30 6.2K devtoolset-7-all-7.0-5.el7.x86_64.rpm 2020-03-12 10:30 3.0K devtoolset-7-binutils-2.28-7.el7.x86_64.rpm 2020-03-23 02:23 5.3M devtoolset-7-binutils-2.28-8.el7.1.x86_64.rpm 2020-03-12 10:30 5.3M devtoolset-7-binutils-2.28-8.el7.sc1.x86_64.rpm 2020-03-23 02:23 5.3M devtoolset-7-binutils-2.28-8.el7.x86_64.rpm 2020-03-23 02:25 5.3M devtoolset-7-binutils-2