简体   繁体   English

XCode编译器错误,使用CMake构建的项目

[英]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. 我正在尝试构建从CMake 3.x生成的XCode(5.0版)项目。

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 -std和-stdlib来自以下项目属性:Apple LLVM 5.0-语言C ++ ==>方言和标准库

How do I set this from CMAKE? 我该如何从CMAKE设置?

If I recall correctly there is no c++0x language dialect in Xcode 5, but there is a c++11 dialect. 如果我没c++0x话,Xcode 5中没有c++0x语言方言,但是有c++11方言。

These properties can be changed in the CMake project in two ways: 可以通过两种方式在CMake项目中更改这些属性:

  • (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 (我从来没有设法做到这一点),方法是先设置CMAKE_XCODE_ATTRIBUTE_ ,然后再设置Xcode项目中看到的属性名称
  • By setting the ''generic'' compiler property CMAKE_CXX_FLAGS variable 通过设置“通用”编译器属性CMAKE_CXX_FLAGS变量

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; 因此,shell看到了两个命令: the first starts with c++ and the second with -std=c++0x . 第一个以c++开头,第二个以-std=c++0x Find and remove that semi-colon and it should start working. 找到并删除该分号,它应该开始工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CMake错误:'目标不是由这个项目构建的' - CMake error: 'target is not built by this project' 将使用ExternalProject_Add构建的库链接到使用CMAKE_CXX_COMPILER配置的项目时出错 - Error linking library built with ExternalProject_Add to project configured with CMAKE_CXX_COMPILER 使用 Xcode 和 GLFW 找不到 CMake 错误 CMAKE_C_COMPILER - CMake error no CMAKE_C_COMPILER could be found using Xcode and GLFW CMake,选择Xcode编译器 - CMake, choose Xcode compiler 从Cmake创建Xcode项目包含不需要的编译器标志 - Creating Xcode project from Cmake contains unwanted compiler flags CMake生成的Xcode项目无法找到从Xcode构建的二进制“产品” - CMake generated Xcode project fails to find the binary “Products” that are built from Xcode CMakeLists.txt:30 (project) 中的 CMake 错误:找不到 CMAKE_C_COMPILER - CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found 使用 Ninja 使用 CMake 构建的 Unicode MFC 应用程序中未解决的 WinMain 错误 - Unresolved WinMain error in Unicode MFC application built with CMake using Ninja 通过CMake在Xcode 4.2项目中使用C ++ 0x - Using C++0x in Xcode 4.2 project via CMake 使用 cmake 构建 Xcode 项目时编译器出现问题 - Problem with compilers when using cmake to build a Xcode project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM