Install GCC with C++14 support on Ubuntu/Mint

  • Deutsch
  • English

The current GCC in the ubuntu repository doesn’t support the C++14 standard. To use the C++14 install the GCC has to be updated manually. It can be found in the Ubuntu Toolchain PPA. After this, the C++ compiler can be updated. The following commands show how to add the repository and install the compiler:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
sudo apt-get update 
sudo apt-get install g++-4.9

After the installation, the compiler can be used by this command:

g++-4.9

The default compiler will not be updated. You can see this because the g++ symlink points to the old g++ version:

ls -l `which g++` 

To set g++4.9 as the default compiler, the symlink in has to be updated:

sudo ln -f -s /usr/bin/g++-4.9 /usr/bin/g++

To check if you are now using the right compiler you can print the GCC version. It should be something like 4.9.X.

g++-4.9

That’s all. Source code can now be compiled like this:

g++ -std=c++14 main.c program