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
g++
? What version of g++ do you have? – muru Sep 10 '14 at 14:13gcc
andg++
packages are separate. Upgradeg++
as well. You have g++ v4.6 now, so c++-11 is not available. – muru Sep 10 '14 at 14:26-std=c++0x
. see updated answer. – αғsнιη Sep 10 '14 at 14:38