Update:
Often people want the most recent version of gcc, and devtoolset is being kept up-to-date, so maybe you want devtoolset-N where N={4,5,6,7...}, check yum for the latest available on your system). Updated the cmds below for N=7.
There is a package for gcc-7.2.1 for devtoolset-7 as an example. First you need to enable the Software Collections, then it's available in devtoolset-7:
You can use the centos-sclo-rh-testing repo to install GCC v7 without having to compile it forever, also enable V7 by default and let you switch between different versions if required.
//required libraries:
yum install libmpc-devel mpfr-devel gmp-devel
yum install zlib-devel*
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++
make -j 8 <== this may take around 75 minutes or less to finish with 8 threads
(depending on your cpu speed)
make install
Result: gcc 8.2.0 and g++ 8.2.0
Installing gcc 7.4(gcc 7.4.0) - released December 6, 2018:
//required libraries:
yum install libmpc-devel mpfr-devel gmp-devel
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++
make -j 8 <== this may take around 50 minutes or less to finish with 8 threads
(depending on your cpu speed)
make install
Result:
Old answer:
Right now, there is no rpm package in order to install gcc 5.3 with yum in CentOS 7.2 or even CentOS 7.3
The solution is to install gcc 5.3 from source code:
curl ftp://ftp.gnu.org/pub/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.bz2 -O
//If you want to verify the downloaded file, use this sig file:
ftp://ftp.gnu.org/pub/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.bz2.sig
tar xvfj gcc-5.3.0.tar.bz2
cd gcc-5.3.0
//here you can add other languages you want to be supported for your gcc like Java or Go,...
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++
// 4 = number of independent central processing units (# of Cores)
make -j 4
make install
2. Use the option --prefix to install gcc to another directory other than the default one. The toplevel installation directory defaults to /usr/local. Read about gcc installation options
Command to install GCC and Development Tools on a CentOS / RHEL 7 server
Type the following yum command as root user:
yum group install "Development Tools"
OR
sudo yum group install "Development Tools"
If above command failed, try:
yum groupinstall "Development Tools"
Update:
Often people want the most recent version of gcc, and devtoolset is being kept up-to-date, so maybe you want devtoolset-N where N={4,5,6,7...}, check yum for the latest available on your system). Updated the cmds below for N=7.
There is a package for gcc-7.2.1 for devtoolset-7 as an example. First you need to enable the Software Collections, then it's available in devtoolset-7:
You can use the centos-sclo-rh-testing repo to install GCC v7 without having to compile it forever, also enable V7 by default and let you switch between different versions if required.
The best approach to use yum and update your devtoolset is to utilize the CentOS SCLo RH Testing repository.
Many additional packages are also available, to see them all
You can use this method to install any dev tool version, just swap the 7 for your desired version. devtoolset-6-gcc, devtoolset-5-gcc etc.
Update: 15 December 2018:
Installing latest major version of gcc: gcc 8 (GCC 8.2.0) - released 07/26/2018:
GCC 8.2 is a bug-fix release for gcc 8.1.0, containing substantial new functionality not available in GCC 7.x or previous GCC releases.
Download file: https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz
Compile and install:
Result: gcc 8.2.0 and g++ 8.2.0
Installing gcc 7.4 (gcc 7.4.0) - released December 6, 2018:
Download file: https://ftp.gnu.org/gnu/gcc/gcc-7.4.0/gcc-7.4.0.tar.gz
Compile and install:
Result:
Old answer:
Right now, there is no rpm package in order to install gcc 5.3 with yum in CentOS 7.2 or even CentOS 7.3
The solution is to install gcc 5.3 from source code:
1: Intstall the required libs
Accept to install the CentOS GPG Key in this step
Install - zlib
2: Download the required source and install
Verify the version:
Notes:
1. This Stack Overflow answer will help to see how to verify the downloaded source file.
2. Use the option
--prefix
to install gcc to another directory other than the default one. The toplevel installation directory defaults to /usr/local. Read about gcc installation options