Install Latest GCC on RHEL 6 x86_64 – Step-by-Step Guide

gccrhelsoftware installation

I have an RHEL 6 server with gcc version 4.4.7. I wanted to update the gcc version (I think the current one is 4.8). Yum update doesn't work. Also, SO answers for a similar question on CentOS does not work. I followed the methods in the accepted answer, the output is "Error getting repository data for testing-1.1-devtools-6, repository not found". Also I am not sure whether I should follow the methods for CentOs.

Has anyone updated gcc in RHEL 6 x86_64 server?

Best Answer

The easiest method by far is to make use of a binary build that's provided through a YUM repository. One such option would be to use the hop5.in repository. Specifically this page: gcc - Various compilers (C, C++, Objective-C, Java, ...). They're providing 4.8.2 which should work with CentOS 6.3 or 6.4. You might want to do an update prior:

$ sudo yum update

The other option would be to make use of the Developer Toolset, specifically the bundled version provided by Scientific Linux.

Following the installation instructions you'll basically do the following 2 steps:

add repositories
$ sudo wget -O /etc/yum.repos.d/slc6-devtoolset.repo \
    http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
$ wget -O /etc/yum.repos.d/slc5-devtoolset.repo \
    http://linuxsoft.cern.ch/cern/devtoolset/slc5-devtoolset.repo
install devtoolset
$ sudo yum install devtoolset-2

Update #1

The hop5.in YUM repository appears to have been removed, so the only recourse is to make use of the devtoolset method highlighted above.

Additional examples for installing via devtoolset are highlighted in this GitHub Gist: Installing gcc 4.8 and Linuxbrew on CentOS 6.

Related Question