I am trying to install the latest version of g++ in Cent OS. The best I managed is the following:

wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutils
yum install devtoolset-2-gcc-c++ devtoolset-2-binutils

But this installs g++ 4.8.2 and not 4.9.2. Is there a way to install 4.9.2?


3 Answers 3


You will have to do it the old fashioned way. Get the GCC sources, build it by hand.

Any reason you are averse to doing this? (I can think of a few, but unless you do too, I don't want to add anything that might be confusing).

If you are hesitant to build from sources, I can probably provide some steps.

NOTE: The reason for that is the devtools with 4.9 is currently only available to Red Hat users with a valid license. Wait for a while, and eventually I am sure 4.9 devtools will be made available to CentOS users too like 4.8 is currently.


CentOS 6/7 officially supports this. You don't need third party repository. And gcc version is 4.9.2 in CentOS's repo.

yum install centos-release-scl-rh          
yum install devtoolset-3-gcc devtoolset-3-gcc-c++   

To use the updated tools, start a new shell using the scl command:

scl enable devtoolset-3 bash

You may also need to reset your PATH environment variable, which might be set in ~/.bashrc or other profile file. If you need to change it, it should point to /opt/rh/devtoolset-3/root/usr/bin/:$PATH

More information on the SCL from CentOS and from Red Hat

  • This didn't work for me. After those 3 steps completed seemingly successful, I still see gcc 4.7.2 when i do gcc -v
    – B T
    Mar 7, 2017 at 8:23
  • Ok, in addition to these steps, I had to change my .bashrc file so that my PATH environment variable was set to /opt/rh/devtoolset-3/root/usr/bin/:$PATH rather than /opt/centos/devtoolset-1.1/root/usr/bin/:$PATH. Then after a session restart it worked.
    – B T
    Mar 7, 2017 at 8:35
  • After using this solution I see that the gcc version really updated (using gcc --version), but I still see the header files from the old version. Moreover, I cannot find most of the newer headers in the directory I expected them to be (/opt/rh/devtoolset-3/root/usr/include/). Why can this happen and how can I solve it?
    – MaMazav
    Jun 12, 2017 at 10:48
  • To make this answer stand the test of time, add yum search devtoolset | grep gcc-c++ to reveal the correct number instead of 3 as in the answer
    – Waslap
    Apr 11, 2019 at 9:42

I use Scientific Linux Cern 6 repository to install gcc 4.9 and g++ 4.9 on my CentOS 6.5 and CentOS 6.6 systems. It does not install g++ 4.9.2. It installs g++ 4.9.1 instead which is good enough for my needs.

Here are the commands I use to install it.

cd /etc/yum.repos.d
wget http://linuxsoft.cern.ch/cern/scl/slc6-scl.repo
yum -y --nogpgcheck install devtoolset-3-gcc devtoolset-3-gcc-c++

As Michael said in his comment to this post, to actually use the version of gcc that this installs, start a new shell with the following command.

scl enable devtoolset-3 bash
  • 1
    To actually use the version of gcc that this installs, start a new shell using scl enable devtoolset-3 bash
    – Michael
    Oct 9, 2015 at 8:55
  • @Michael Thank you for mentioning this. I have included your comment in my answer now to make the answer more helpful.
    – Susam Pal
    Oct 9, 2015 at 12:29
  • Also didn't work for me. Same as for Jesse's answer
    – B T
    Mar 7, 2017 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.