I just came back from cppcon 2017, and there were so much information about c++17 or c++2x. I just can’t wait to try out thoes features. I found lots of new versions of gcc/g++ are not ready in package form on most of OS, including CentOS/RHEL. The latest packaged gcc I can find is the one comes with Devtoolset-6
, which only supports up to c++14. Here are the steps to install any custom versions of gcc/g++ on CentOS/RHEL.
Install dependencies in order to build gcc
1
$ sudo yum -y install libmpc-devel mpfr-devel gmp-devel gcc-g++ zlib-devel
For example, I want to install the latest stable version of gcc, which is gcc 7.2.0. You can find all versions here and modify the url to download the version you want.
1
$ curl ftp://ftp.gnu.org/pub/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz -O
Uncompress it
1
$ tar xvf gcc-7.2.0.tar.gz
Configure it
1
2$ cd gcc-7.2.0
$ ./configure --with-system-zlib --disable-multilib --enable-languages=c,c++Build it and install it
1
2$ make -j 8
$ sudo make installBy default it will install all stuff to
/usr/local/
. And you are done!Type
/usr/local/bin/gcc -v
should show you the correct version.
If you just want to try out new few features in a very light-weight form, wandbox is the best tool you can use without installing anything!