4

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?

justin
  • 104,054
  • 14
  • 179
  • 226
Prin_E
  • 41
  • 1
  • 2
  • 1
    If you hit the "run" button, does it compile and run anyway? – Howard Hinnant Aug 02 '11 at 14:52
  • 2
    Oh, i found it. libc++ as standard library requires OS X Lion! (...) I changed libc++ to libstdc++ and it compiled successfully. – Prin_E Aug 02 '11 at 15:05
  • 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 http://libcxx.llvm.org/ . – Howard Hinnant Aug 02 '11 at 15:08
  • 3
    @Prin_E congratulations on figuring it out. Please post this as an *answer* and accept it to mark the question resolved. – spraff Oct 10 '11 at 10:39

2 Answers2

5

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

Ted Spradley
  • 3,414
  • 3
  • 22
  • 26
  • Make sure to set the `Compiler for C/C++/Objective-C` option to `Apple LLVM Compiler 3.x`, otherwise the options listed above won't appear. That said, does anyone know why the Apple LLVM compiler is the only one that lets one specify the C++ standard library? – cjcurrie Jan 15 '13 at 23:11
1

From the comments:

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

Bo Persson
  • 90,663
  • 31
  • 146
  • 203