🌐
Wupingxin
blog.wupingxin.net › install-gcc-6-1-0-on-centos-7
Install gcc 6.1.0 on CentOS 7 – Wuping Xin Blog
August 7, 2020 - The default gcc on CentOS 7 is 4.8.5. Installing gcc 6.1 on CentOS 7 is not possible using yum install.
Discussions

Need to update gcc to version >=6 on CentOS 7 ? - Discuss - lists.centos.org
NFS Server on Centos 7.6.1810... More on lists.centos.org
🌐 lists.centos.org
Is there a RPM package for GCC 6.2 for Cent OS 7.2 ? Looks there is only source. I am trying to compile and it is running hours ? any idea - Stack Overflow
Is there a RPM package for GCC 6.2 for Cent OS 7.2 ? Looks there is only source. I am trying to compile and it is running for hours. Any idea how long will it take to build the binaries ? ... Check the devtoolset packages. – Matthew Schuchard Commented Jan 20, 2017 at 12:35 ... I've been looking around a little on rpm.pbone.net; but it seems like there is no gcc 6.2 for centos7 ... More on stackoverflow.com
🌐 stackoverflow.com
installation - How to Install gcc 5.3 with yum on CentOS 7.2? - Stack Overflow
Update: Often people want the most ... N={4,5,6,7...}, check yum for the latest available on your system). Updated the cmds below for N=7. There is a package for gcc-7.2.1 for devtoolset-7 as an example. First you need to enable the Software Collections, then it's available in devtoolset-7: sudo yum install centos-release-scl ... More on stackoverflow.com
🌐 stackoverflow.com
September 28, 2016
Devtoolset is a game changer for C++ development on Linux

what is devtoolset ?

More on reddit.com
🌐 r/cpp
31
20
March 23, 2018
🌐
Linux Tips
linux-tips.com › programming
Installing gcc versions on Centos7 / Redhat7 - Programming - Linux Tips
September 20, 2018 - Centos7 and Redhat7 still uses too old gcc 4.8.5 version and this becomes very annoying if you want to use newer features in your C/C++ programs. You can install these newer versions with Devtoolset-4 from the Software Collections project.
🌐
Blogger
devlucidmaj7.blogspot.com › 2020 › 04 › installing-centos7-gcc-6x.html
Installing CentOS7 GCC 6.x
April 22, 2020 - Installing CentOS7 GCC 6.x Installing GCC on CentOS 7 will install version 4.8.5. In some cases, you may need to install a higher versio...
🌐
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 - 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 · You learned how to install GNU c, c++ compilers and releated tools on a CentOS or Red Hat Enterprise Linux version 7.x. See GCC site for more info.
🌐
Centos
lists.centos.org › hyperkitty › list › discuss@lists.centos.org › thread › GYWBBM7QIICFFQGBLNCU2Y3PQB4VLVX2
Need to update gcc to version >=6 on CentOS 7 ? - Discuss - lists.centos.org
I need to build u-boot on my CentOS 7 machine but encounter this: ... *** Your GCC is older than 6.0 and is not supported · I've updated the installation on my machine but the current version is: ... gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) How do I go about updating gcc to version 6 or greater on my CentOS 7 machine?
🌐
GitHub
gist.github.com › stephenturner › e3bc5cfacc2dc67eca8b
Installing gcc 4.8 and Linuxbrew on CentOS 6 · GitHub
Here's how I upgraded gcc on my latest 6.7 build. $ 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) ...
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.

Find elsewhere
🌐
LinuxHostSupport
linuxhostsupport.com › home › how to install gcc on centos 7
How To Install GCC on CentOS 7 | LinuxHostSupport
May 24, 2019 - In this tutorial, we will take a look at how to install GCC on CentOS 7. GCC or GNU Compiler Collection is released by the Free Software Foundation and as
🌐
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 devtoolset-7-gcc* Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.crazyfrogs.org * extras: centos.quelquesmots.fr * updates: centos.mirror.fr.planethoster.net centos-sclo-rh | 3.0 kB 00:00:00 centos-sclo-sclo | 2.9 kB 00:00:00 (1/2): centos-sclo-sclo/x86_64/primary_db | 281 kB 00:00:00 (2/2): centos-sclo-rh/x86_64/primary_db | 3.5 MB 00:00:03 Resolving Dependencies --> Running transaction check ---> Package devtoolset-7-gcc.x86_64 0:7.3.1-5.4.el7 will be installed --> Processing Dependency: glibc-devel >= 2.2.90-12 for package:
🌐
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 - 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$(nproc) sudo make install gcc --version
🌐
Stack Overflow
stackoverflow.com › questions › 41760774 › is-there-a-rpm-package-for-gcc-6-2-for-cent-os-7-2-looks-there-is-only-source
Is there a RPM package for GCC 6.2 for Cent OS 7.2 ? Looks there is only source. I am trying to compile and it is running hours ? any idea - Stack Overflow
... Check the devtoolset packages. – Matthew Schuchard Commented Jan 20, 2017 at 12:35 ... I've been looking around a little on rpm.pbone.net; but it seems like there is no gcc 6.2 for centos7 available.
Top answer
1 of 6
233

Update:
Often people want the most recent version of gcc, and devtoolset is being kept up-to-date, so maybe you want devtoolset-N where N={4,5,6,7...}, check yum for the latest available on your system). Updated the cmds below for N=7.

There is a package for gcc-7.2.1 for devtoolset-7 as an example. First you need to enable the Software Collections, then it's available in devtoolset-7:

sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
which gcc
gcc --version
2 of 6
78

Update: Installing latest version of gcc 9: (gcc 9.3.0) - released March 12, 2020:

Same method can be applied to gcc 10 (gcc 10.1.0) - released May 7, 2020

Download file: gcc-9.3.0.tar.gz or gcc-10.1.0.tar.gz

Compile and install:

//required libraries: (some may already have been installed)
dnf install libmpc-devel mpfr-devel gmp-devel

//if dnf install libmpc-devel is not working try:
dnf --enablerepo=PowerTools install libmpc-devel

//install zlib
dnf install zlib-devel*

./configure --with-system-zlib --disable-multilib --enable-languages=c,c++

make -j 8 <== this may take around an hour or more to finish
              (depending on your cpu speed)

make install

Tested under CentOS 7.8.2003 for gcc 9.3 and gcc 10.1

Tested under CentOS 8.1.1911 for gcc 10.1 (may take more time to compile)

Results: gcc/g++ 9.3.0/10.1.0

Installing gcc 7.4 (gcc 7.4.0) - released December 6, 2018:

Download file: https://ftp.gnu.org/gnu/gcc/gcc-7.4.0/gcc-7.4.0.tar.gz

Compile and install:

//required libraries:
yum install libmpc-devel mpfr-devel gmp-devel

./configure --with-system-zlib --disable-multilib --enable-languages=c,c++

make -j 8 <== this may take around 50 minutes or less to finish with 8 threads
              (depending on your cpu speed)


make install

Result:

Notes:

1. This Stack Overflow answer will help to see how to verify the downloaded source file.

2. Use the option --prefix to install gcc to another directory other than the default one. The toplevel installation directory defaults to /usr/local. Read about gcc installation options

🌐
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 - Developer Toolset 6 · In this example, we’ll install the Developer Toolset version 7. To do so type the following command on your CentOS 7 terminal: Terminal · sudo yum install devtoolset-7 · To access GCC version 7, you need to launch a new shell instance using the Software Collection scl tool: Terminal ·
🌐
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 - Optional: Permanently enable GCC 8 and Clang 6 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 # yum install devtoolset-8 llvm-toolset-6.0 # yum install llvm-toolset-6.0-clang-analyzer llvm-toolset-6.0-clang-tools-extra # optional # exit $ scl enable devtoolset-8 llvm-toolset-6.0 bash $ gcc --version gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3) $ clang --version clang version 6.0.1 (tags/RELEASE_601/final) $ # Optionally permanently enable GCC 8 / Clang/LLVM 6.0 $ echo "source scl_source enable devtoolset-8 llvm-toolset-6.0" &amp;amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;gt; ~/.bashrc
🌐
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 ...