How to Install gcc 4.7.x/4.8.x on CentOS
Solution 1
Tru Huynh of centos.org 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
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
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++
Solution 2
Here is how to get devtoolset-2 (including gcc 4.8.1)
This was taken from http://people.centos.org/tru/devtools-2/readme
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 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)
Solution 3
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 http://www.scientificlinux.org/documentation/gpg/RPM-GPG-KEY-cern
Enjoy!
Solution 4
# 1. Install a package with repository for your system:
# RHEL 6: `yum-config-manager --enable rhel-server-rhscl-6-rpmss`
# RHEL 7: `yum-config-manager --enable rhel-server-rhscl-7-rpms`
$ sudo yum install centos-release-scl # On CentOS 6/7+, install package centos-release-scl available in CentOS repository
# 2. Install the collection:
$ sudo yum install devtoolset-3
# 3. Start using software collections:
$ scl enable devtoolset-3 bash
$ sudo yum list devtoolset-3\*
Solution 5
there is a problem with devtool1.1 so I did some changes - finally, this worked for me : first run
yum clean all
than :
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo -O /etc/yum.repos.d/devtools-1.1.repo
now open /etc/yum.repos.d/devtools-1.1.repo and change from :
http://people.centos.org/tru/devtools-2/$releasever/$basearch/RPMS
(if you are using x86_64)to:
http://people.centos.org/tru/devtools-1.1/6/x86_64/RPMS/
or ((if you are using x86))
http://people.centos.org/tru/devtools-1.1/6/i386/RPMS/
and finally run :
yum install devtoolset-1.1
Related videos on Youtube
Tomas Andrle
Application and game development. Tiny Player, Superforce, Devastro and more.
Updated on September 18, 2022Comments
-
Tomas Andrle over 1 year
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 ofgcc
. -
Tomas Andrle over 12 yearsI asked about 4.7 because it is supposed to have some C++11 features that I need (porting from Clang).
-
Tomas Andrle over 12 yearsSo apart from compiling from source there is no, say, website that would have some rpms I could use?
-
bbaja42 over 12 yearsNot 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.
-
Admin about 11 yearsrunning
yum --enablerepo=testing-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++
returns a four-o-four, .. : image -
ck_ about 11 yearsThanks for reporting that, looks like he changed the url and repo name slightly for 1.1 and I had just edited it from 1.0 - I fixed it now, I think people.centos.org/tru/devtools-1.1
-
Admin about 11 yearsdon't forget to
yum clean all
before doing the steps again after failure else you will still get 404 -
marcin about 11 yearsinstead of setting individual variables you can do
scl enable devtoolset-1.1 bash
(it starts new shell with all variables set). -
dwurf about 10 yearsFor g++ 4.8.2, change
1.1
to2
everywhere, and change--enablerepo=testing-1.1-devtools-6
to--enablerepo=testing-devtools-2-centos-6
-
Paul Praet almost 10 yearsDoes this still work ? I get people.centos.org/tru/devtools-2/6Workstation/i386/RPMS/…: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
-
Zeks almost 10 yearsit does work, the only problem is that for some reason yum will now try to access: people.centos.org/tru/devtools-2/6Server/x86_64/RPMS/repodata/… notice 6Server here which is wrong. To get the package you need to edit your repo file to contain this instead of its contents: people.centos.org/tru/devtools-2/6/x86_64/RPMS
-
Naveen Sharma over 8 yearsif you run into assembler errors, don't forget to update your binutils
yum install devtoolset-2-gcc devtoolset-2-binutils
-
codecowboy over 8 yearswhat does
hash -r
do? -
codecowboy over 8 yearsln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/ broke sudo on my Centos 6.7 system. I think it might alias sudo.
-
Denis Denisov over 8 years@codecowboy
$PATH
every time you type a command by caching the results in memory,hash -r
force reload $PATH -
Manuel J. Diaz over 8 yearsFYI: the above answer still works as of Feb 10 2015 on CentOS 6.7.
-
slm about 8 years@Denji - apparently the hop5.in site is no more.
-
jemiloii about 8 yearsI had to export these for it to work. Thanks! export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++ export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp
-
Mark Lakata about 8 years@JemiloII - did you do
scl enable devtoolset-2
after installing? That should work to get the correct compilers on the path. -
jemiloii about 8 yearsthat actually works better than the exports!
-
B T almost 8 yearsI'm getting
http://people.centos.org/tru/devtools-1.1/7/x86_64/RPMS/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
-
Swanidhi almost 8 years@MarkLakata - Running
scl enable devtoolset-2
throws the following errorNeed at least 3 arguments. Run scl --help to get help.
-
Mark Lakata almost 8 years@Swanidhi The full command is
scl enable devtoolset-2 bash
where the last field could be different if you are not using bash. -
GeorgeKaf over 7 yearsStill works in September 2016. Tried it for a sass gem and library github.com/sass/sassc-ruby/issues/37#issuecomment-248959463. No errors in Centos 6.8
-
Weekend over 7 yearsIt seems that
devtoolset-2
is the last version which supports 32-bit. -
FooBee almost 7 yearsmay need add
--nogpgcheck
option :sudo yum install --nogpgcheck devtoolset-3
-
Remo Harsono over 6 yearsthe link above is broken now, I found similar key here: [ftp.riken.jp] (ftp.riken.jp/Linux/cern/slc58/x86_64/RPM-GPG-KEYs/…)
-
riv about 3 yearsI'm getting "Connecting to people.centos.org|...|:80... connected. - HTTP request sent, awaiting response... 403 Forbidden"