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.
Best Answer
Now
devtools-8
is available and it's possible to use it by following commands:It's explained in a little more detail in this answer on StackOverflow: How to install GCC/G++ 8 on CentOS. And of course, if you need
GFortran
, you can install it in the same way - the package isdevtoolset-8-gcc-gfortran
.