I just followed an answer to this question to update my gcc version to 4.8. 1 on Ubuntu 12.04, which I thought would support C++11. However it does not seem to.
When I try to compile something with -std=c++11 flag, I get this error:
cc1plus: error: unrecognized command line option ‘-std=c++11’My gcc version is this:
gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04)My g++ version is this:
$ g++ -v ....
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)What could I be missing?
Edit: I was missing that I needed to update g++
It is easily achieved with a small modification to the code provided in the above mentioned answer. Just change gcc to g++.
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 5 1 Answer
You have upgraded the C compiler, but not the C++ compiler. They are separate binary packages. You need to also install the g++-4.8 package to get the new version of the C++ compiler.