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
$ 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.
$ curl ftp://ftp.gnu.org/pub/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz -O
$ tar xvf gcc-7.2.0.tar.gz
$ cd gcc-7.2.0
$ ./configure --with-system-zlib --disable-multilib --enable-languages=c,c++
Build it and install it
$ make -j 8
$ sudo make install
By default it will install all stuff to
/usr/local/. And you are done!
/usr/local/bin/gcc -vshould 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!