简体   繁体   中英

XCode compiler error, with a project built using CMake

I'm trying to build a XCode (version 5.0) project that was generated from CMake 3.x.

clang compiler version:
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

When I try to build the project

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 blah blah  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk  blah blah -Wno-unknown-pragmas -F/usr/local/bin/Debug ;**-std=c++0x -stdlib=libc++** -Wall -MMD -MT blah blah

I get this error:

clang: error: no such file or directory: ';-std=c++0x'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

How can I fix this error?

-std and -stdlib are coming from these project properties: Apple LLVM 5.0 - Language C++ ==> Dialect and Standard library

How do I set this from CMAKE?

If I recall correctly there is no c++0x language dialect in Xcode 5, but there is a c++11 dialect.

These properties can be changed in the CMake project in two ways:

  • (I've never managed to do this) by setting CMAKE_XCODE_ATTRIBUTE_ and then the name of the attribute you see in the Xcode project
  • By setting the ''generic'' compiler property CMAKE_CXX_FLAGS variable

There is a stray semi-colon in that command line:

-F/usr/local/bin/Debug ;-std=c++0x -stdlib=libc++ 
                       ^

So the shell is seeing two commands; the first starts with c++ and the second with -std=c++0x . Find and remove that semi-colon and it should start working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM