4
votes

I'm using Macbook 1g, Snow Leopard.

Few days ago i installed xcode 4.2 and made a test project for c++0x.

I set LLVM 3.0 as c++ compiler, C++ Language Dialect as C++0x and C++ Standard Library as libc++.

but when building, error occured.

"iostream" file not found

I find it most bewildering. How can I solve this problem?

2
If you hit the "run" button, does it compile and run anyway? - Howard Hinnant
Oh, i found it. libc++ as standard library requires OS X Lion! (...) I changed libc++ to libstdc++ and it compiled successfully. - Prin_E
I don't know about running under Xcode, but if you want to try clang+libc++ on Snow Leopard with a command line interface, you can try the "get it" directions at libcxx.llvm.org . - Howard Hinnant
@Prin_E congratulations on figuring it out. Please post this as an answer and accept it to mark the question resolved. - spraff

2 Answers

5
votes

"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.

Edit - Nothing like a nap to clear the head.

Be sure to make the file name suffix of the implementation file to be ".mm".

Project->Build Settings->Apple LLVM compiler 3.1-Language-> Then: C++ Language Dialect->C++11 (or whatever option) C++ Standard Library->libstdc++

And don't forget this last one! Compile Sources as->Objective-C++

1
votes

From the comments:

Oh, i found it. libc++ as standard library requires OS X Lion! (...) I changed libc++ to libstdc++ and it compiled successfully.