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.
- 10,249
- 3,102
8 Answers
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++
- 1,905
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/centosis no longer used/opt/rhis now used as upstream (as SL version)
- 5,583
- 8,930
- 2
- 19
- 16
-
1I 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 – jemiloii Mar 09 '16 at 19:49
-
2@JemiloII - did you do
scl enable devtoolset-2after installing? That should work to get the correct compilers on the path. – Mark Lakata Mar 09 '16 at 21:58 -
-
@MarkLakata - Running
scl enable devtoolset-2throws the following errorNeed at least 3 arguments. Run scl --help to get help.– Swanidhi Jul 05 '16 at 15:45 -
3@Swanidhi The full command is
scl enable devtoolset-2 bashwhere the last field could be different if you are not using bash. – Mark Lakata Jul 05 '16 at 17:16 -
-
I'm getting "Connecting to people.centos.org|...|:80... connected. - HTTP request sent, awaiting response... 403 Forbidden" – riv Mar 08 '21 at 14:51
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!
- 9,334
- 409
-
1the link above is broken now, I found similar key here: [ftp.riken.jp] (http://ftp.riken.jp/Linux/cern/slc58/x86_64/RPM-GPG-KEYs/RPM-GPG-KEY-cern) – Remo Harsono Nov 10 '17 at 08:36
# 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\*
- 317
- 1
- 3
- 6
-
1
-
ln -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. – codecowboy Jan 13 '16 at 09:29
-
@codecowboy
$PATHevery time you type a command by caching the results in memory,hash -rforce reload $PATH – Denis Denisov Jan 13 '16 at 12:04 -
-
may need add
--nogpgcheckoption :
sudo yum install --nogpgcheck devtoolset-3– FooBee Jul 13 '17 at 08:17
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.
- 3,031
-
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
- 121
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
- 121
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
- 1,605
yum --enablerepo=testing-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++returns a four-o-four, .. : image – Mar 12 '13 at 07:28yum clean allbefore doing the steps again after failure else you will still get 404 – Mar 12 '13 at 11:18scl enable devtoolset-1.1 bash(it starts new shell with all variables set). – marcin Mar 28 '13 at 11:421.1to2everywhere, and change--enablerepo=testing-1.1-devtools-6to--enablerepo=testing-devtools-2-centos-6– dwurf Apr 15 '14 at 23:28yum install devtoolset-2-gcc devtoolset-2-binutils– nxshar2 Oct 21 '15 at 07:54http://people.centos.org/tru/devtools-1.1/7/x86_64/RPMS/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found– B T Jun 16 '16 at 08:12