How to install g++ 4.9.2 in Cent OS 6.5?

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


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

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.

Tags:

Linux