I needed to compile some source that required a newer version of the GNU GCC compiler than the ancient 4.4.7 20120313 that comes with my fully-up-to-date CentOS 6.5 Linux system. Following the steps below, I was able to install and use devtools-2 which contains a fully functioning 4.8.2 20140120 version of the GNU GCC compiler environment.
- Go to the /etc/yum.repos.d/ directory on your system and download the devtools-2.repo file from http://people.centos.org/tru/devtools-2/:
- Install the gcc, binutils, fortran, and C++ packages with:
- Use the “scl” command to open a shell which is running in the devtools environment:
cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-2/devtools-2.repo
yum install devtoolset-2-gcc
yum install devtoolset-2-binutils
yum install devtoolset-2-gcc-gfortran
yum install devtoolset-2-gcc-c++
scl enable devtoolset-2 bash
No mess, no fuss! The devtools-2 environment is fully self-contained and doesn’t impact your distro’s base compiler environment.
=========== UPDATE =============
# 1. Install a package with repository for your system:
# On CentOS, install package centos-release-scl available in CentOS repository:
$ sudo yum install centos-release-scl
# On RHEL, enable RHSCL repository for you system:
$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
# 2. Install the collection:
$ sudo yum install devtoolset-6
# 3. Start using software collections:
$ scl enable devtoolset-6 bash