The original recipe for building C++ concepts with GCC 6.0.
The easiest and most secure way of using beta versions of Gnu Compiler Collection (GCC), is to create a separate account for that. I would not recommend using your personal everyday account with a new beta compiler. You’ll never know when you’ve forgotten about GCC testing, and you’re building some other application using a beta version of the compiler.
useradd -m betagcc
su - betagcc
git clone https://github.com/gcc-mirror/gcc.git
cd gcc
./configure --disable-bootstrap --enable-languages=c,c++ --prefix=${HOME}/gccbin
make -j3
mkdir -p ~/bin
ln -sf ${HOME}/gccbin/bin/g++ ~/bin/g++
PATH=~/bin:$PATH
source .bashrc
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/betagcc/gccbin/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --disable-bootstrap --enable-languages=c,c++
Thread model: posix
gcc version 6.0.0 20150807 (experimental) (GCC)
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/betagcc/gccbin/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --disable-bootstrap --enable-languages=c,c++ --prefix=/home/betagcc/gccbin/ : (reconfigured) ./configure --disable-bootstrap --enable-languages=c,c++ --prefix=/home/betagcc/gccbin/
Thread model: posix
gcc version 7.0.0 20160704 (experimental) (GCC)
After it became apparent concepts did not make it into the C++17 standard, concepts where no longer available through either the -std=c++1z
or -std=-std=gnu++1z
command line switches to g++.
From version 6.1 of GCC, only the command line switch -fconcepts
will enable the C++ concepts extension. If you upgrade from 6.0 to 6.1 or later, GCC will put a friendly reminder that the requires
keyword requires -fconcepts
.
Error when using 7.x version of GCC, and trying to use concepts without -fconcepts
.
error: 'requires' only available with -fconcepts
When instructed to build with concepts, the -fconcepts
will be used exclusively.
If you try to use -fconcepts
in a too old compiler, g++ will complain.
g++: error: unrecognized command line option '-fconcepts'
Professional Software Developer, doing mostly C++. Connect with Kent on Twitter.