Xcode 4.2 + c++0x/libc++ 找不到 iostream
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6913637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4.2 + c++0x/libc++ cannot find iostream
提问by Prin_E
I'm using Macbook 1g, Snow Leopard.
我正在使用 Macbook 1g,Snow Leopard。
Few days ago i installed xcode 4.2 and made a test project for c++0x.
几天前我安装了 xcode 4.2 并为 c++0x 做了一个测试项目。
I set LLVM 3.0 as c++ compiler, C++ Language Dialect as C++0x and C++ Standard Library as libc++.
我将 LLVM 3.0 设置为 c++ 编译器,将 C++ 语言方言设置为 C++0x,将 C++ 标准库设置为 libc++。
but when building, error occured.
但是在构建时,发生了错误。
"iostream" file not found
I find it most bewildering. How can I solve this problem?
我觉得它最令人困惑。我怎么解决这个问题?
回答by Ted Spradley
"I changed libc++ to libstdc++". How? Where is this setting? Apple documentation says "simply set "C++ Standard Library Type" in the build settings to ... " Build settings is long and I don't see the place to set. Thanks.
“我将 libc++ 更改为 libstdc++”。如何?这个设置在哪里?Apple 文档说“只需在构建设置中将“C++ 标准库类型”设置为...“构建设置很长,我看不到设置的位置。谢谢。
Edit - Nothing like a nap to clear the head.
编辑 - 没有什么比打盹更能让头脑清醒的了。
Be sure to make the file name suffix of the implementation file to be ".mm".
务必使实现文件的文件名后缀为“.mm”。
Project->Build Settings->Apple LLVM compiler 3.1-Language-> Then: C++ Language Dialect->C++11 (or whatever option) C++ Standard Library->libstdc++
Project->Build Settings->Apple LLVM compiler 3.1-Language-> Then: C++ Language Dialect->C++11 (or any option) C++ Standard Library->libstdc++
And don't forget this last one! Compile Sources as->Objective-C++
别忘了最后一个!将源编译为->Objective-C++
回答by Bo Persson
From the comments:
来自评论:
Oh, i found it. libc++ as standard library requires OS X Lion! (...) I changed libc++ to libstdc++ and it compiled successfully.
哦,我找到了。libc++ 作为标准库需要 OS X Lion!(...) 我将 libc++ 更改为 libstdc++ 并成功编译。