Mac上的C ++ 11与Clang或GCC [英] C++11 on Mac with Clang or GCC

查看:1422
本文介绍了Mac上的C ++ 11与Clang或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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆