Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What would be the easiest way to install gcc 4.7.x/4.8.x on a system with CentOS 6.2+? The default RPM package contains an older version of gcc.

share|improve this question

8 Answers 8

Tru Huynh of has built the redhat developer toolset 1.1, for centos and it contains gcc 4.7.2

So you could simply use his repo and install just gcc, instantly.

cd /etc/yum.repos.d
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++

This will install it most likely into /opt/centos/devtoolset-1.1/root/usr/bin/

Then you can tell your compile process to use the gcc 4.7 instead of 4.4 with the CC variable

export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc  
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++
share|improve this answer
running yum --enablerepo=testing-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++ returns a four-o-four, .. : image – user144773 Mar 12 '13 at 7:28
don't forget to yum clean all before doing the steps again after failure else you will still get 404 – user144773 Mar 12 '13 at 11:18
instead of setting individual variables you can do scl enable devtoolset-1.1 bash (it starts new shell with all variables set). – marcin Mar 28 '13 at 11:42
For g++ 4.8.2, change 1.1 to 2 everywhere, and change --enablerepo=testing-1.1-devtools-6 to --enablerepo=testing-devtools-2-centos-6 – dwurf Apr 15 '14 at 23:28
Does this still work ? I get…: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404" – Paul Praet May 21 '14 at 9:21

There is new version of devtoolset 2.0. Nice people from Cern working on Scientific Linux created an open version:

If you use CentOS (not Scientific Linux), then you will have to import their GPG key from here using:

rpm --import


share|improve this answer
The link for the GPG key above is broken, I found a mirror here:… – staticfloat Sep 27 '14 at 22:23

Here is how to get devtoolset-2 (including gcc 4.8.1)

This was taken from

wget -O /etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

Known issues:

  • unsigned packages
  • CentOS-6 devtoolset-2 needs devtoolset-2-ide which contains the whole Eclipse stack, but does not build yet
  • CentOS-6 all the maven related file are not built either

Main changes from devtools-1.1:

  • /opt/centos is no longer used
  • /opt/rh is now used as upstream (as SL version)
share|improve this answer

EL6 gcc-4.8

or this /etc/yum.repos.d/DevToolset.repo

name=RedHat DevToolset v2 $releasever - $basearch

Testing run

# yum install devtoolset-2-gcc-4.8.2 devtoolset-2-gcc-c++-4.8.2
# /opt/rh/devtoolset-2/root/usr/bin/gcc --version


ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/
hash -r
gcc --version


share|improve this answer

From what I can see from the gnu gcc, latest stable version is 4.62. The version 4.7 can be downloaded and compiled, more info on the gcc installation.

share|improve this answer
I asked about 4.7 because it is supposed to have some C++11 features that I need (porting from Clang). – Tomas Andrle Jan 22 '12 at 19:01
So apart from compiling from source there is no, say, website that would have some rpms I could use? – Tomas Andrle Jan 22 '12 at 19:02
Not that I'm aware of, but I'm not very knowledgeable on the topic. RPM repository typicly include the RPM only in it's stable form. – bbaja42 Jan 22 '12 at 20:28

neither one of these answers worked for me.
even in the shell of devtoolset is still saw my gcc 4.4.7.
My trick was the following:

mv /usr/bin/gcc /usr/bin/gcc.bckup
ln -s /opt/centos/devtoolset-1.1/root/usr/bin/gcc /usr/bin/gcc
share|improve this answer

One way of achieving this would be to fetch src RPMs from the fedora repositories and recompile them for your target system.
Fedora 17 and later provide gcc 4.7

share|improve this answer

there is a problem with devtool1.1 so I did some changes - finally, this worked for me : first run

yum clean all

than :

wget -O /etc/yum.repos.d/devtools-1.1.repo

now open /etc/yum.repos.d/devtools-1.1.repo and change from :$releasever/$basearch/RPMS

(if you are using x86_64)to: 

or ((if you are using x86))

and finally run :

yum install devtoolset-1.1
share|improve this answer

protected by bwDraco Feb 8 at 14:53

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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