Mac上的C ++ 11与Clang或GCC [英] C++11 on Mac with Clang or GCC
问题描述
我在Moutain Lion上有Xcode 4.5.2,我安装了最后的命令行工具,但是当我试图用 g ++
或 clang ++
(和选项 -std = c ++ 11 -stdlib = libc ++
)我得到一个错误。
使用 g ++
:
cc1plus:error:unrecognized命令行选项-std = c ++ 11
cc1plus:错误:无法识别的命令行选项-stdlib = libc ++
clang ++
:
clang:错误:-stdlib = libc ++的无效部署目标(需要OS X 10.7或更高版本)
Qt项目。
那么如何在Mac上使用C ++ 11呢?
正如你所发现的,g ++不支持这些命令行选项。
这听起来像你在使用Xcode。
$ b
对于clang,您应该查看项目设置,并确保部署目标设置为10.7(或10.8)
错误信息告诉你libc ++不能用于10.6和之前。
I have Xcode 4.5.2 on Moutain Lion, and I have install the lastest "Command Line Tools" but when I tried to compile with g++
or clang++
(and the options -std=c++11 -stdlib=libc++
) I get an error.
With g++
:
cc1plus: error: unrecognized command line option "-std=c++11"
cc1plus: error: unrecognized command line option "-stdlib=libc++"
With clang++
:
clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
It's in a Qt project.
So how can I used the C++11 on my Mac ?
As you found, g++ does not support those command line options.
It sounds like you're using Xcode.
For clang, you should look at the project settings, and make sure that the "Deployment Target" is set to 10.7 (or 10.8)
What the error message is telling you is that libc++ is not available for 10.6 and before.
这篇关于Mac上的C ++ 11与Clang或GCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!