I am trying to compile some c++11 code on ubuntu 12.04. After invoking my makefile I got
我正在尝试在ubuntu 12.04上编译一些c++11代码。在调用我的makefile之后,我得到了
cc1plus: error: unrecognized command line option ‘-std=c++11’
错误:无法识别的命令行选项' -std=c+ 11 '
Ubuntu gcc 4.7. Fine, so I ran
Ubuntu gcc 4.7。很好,所以我跑
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7
Ran it again, and still the same problem. Great.So then I tried changing the symlink of gcc from gcc4.6 to 4.7. After doing this, it then went and complained about not being able to find g++. So I then ran
再运行一次,仍然是同样的问题。太好了。于是我尝试将gcc的符号链从gcc4.6改为4.7。这样做之后,它就开始抱怨找不到+ g。所以我就跑
sudo apt-get update
sudo apt-get install build-essential
Still no luck. When I typed g++, I just got
仍然没有运气。当我输入g++时,我刚得到
The program 'g++' can be found in the following packages:
*g++
*pentium_builder
Try: sudo apt-get install <selected package>可以在下面的包中找到“g++”程序:*g++ *pentium_builder: sudo apt-get install
。
So I then tried
所以我就试着
sudo apt-get install pentium_builder
Now I get
现在我得到
Unable to exec g++.real: No such file or directory
无法执行g + +。真实:没有这样的文件或目录
How I can compile c++11 code?
如何编译c++11代码?
2 个解决方案
#1
1
Last time I tried, the following worked for me for installing and setting g++ 4.8 as default:
上次我试过了,在安装和设置g+ 4.8为默认值时,如下所示:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
It seemed painless, and I was able to choose which gcc/g++ version to use without manually setting up symlinks. I suspect this would work for gcc 4.7 as well.
这看起来很简单,我可以选择使用哪个gcc/g++版本,而无需手动设置符号链接。我怀疑这对gcc 4.7也适用。
#2
0
Add the following to your Makefile:
向您的Makefile中添加以下内容:
PROJECT_CFLAGS = -std=c++0x
#1
1
Last time I tried, the following worked for me for installing and setting g++ 4.8 as default:
上次我试过了,在安装和设置g+ 4.8为默认值时,如下所示:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
It seemed painless, and I was able to choose which gcc/g++ version to use without manually setting up symlinks. I suspect this would work for gcc 4.7 as well.
这看起来很简单,我可以选择使用哪个gcc/g++版本,而无需手动设置符号链接。我怀疑这对gcc 4.7也适用。
#2
0
Add the following to your Makefile:
向您的Makefile中添加以下内容:
PROJECT_CFLAGS = -std=c++0x