Building GCC with Concepts Lite

By , last updated September 12, 2016

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.

  1. As root, make a user account for testing GCC:
    useradd -m betagcc
  2. Change to the new user:
    su - betagcc
  3. Clone GCC from somewhere. The mirror on GitHub is as good as any:
    git clone
  4. Wait a moment for everything to clone. Enter the gcc folder:
    cd gcc
  5. Configure with C and C++ enabled:
    ./configure --disable-bootstrap --enable-languages=c,c++ --prefix=${HOME}/gccbin
  6. Make. This will take a long time. Speed up the process by using the -j parameter with number of cores in your system.
    make -j3
  7. Make a bin-folder if you don’t have it already.
    mkdir -p ~/bin
  8. Create a symbolic link from ${HOME}/bin/g++ to ${HOME}/gccbin/bin/g++.
    ln -sf ${HOME}/gccbin/bin/g++ ~/bin/g++
  9. Add ~/bin to PATH. Add it to the beginning because you’re overriding g++ from the system. Add this line to .bashrc:
  10. Source .bashrc to add ~/bin to your path.
    source .bashrc
  11. Test that you’re using the correct g++ version with -v.
    $ g++ -v
    Using built-in specs.
    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)
  12. A later version of GCC will be identified by:
    Using built-in specs.
    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)

Using concepts with g++

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.


Be the first to comment.

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>