我正在尝试编译一个使用
的 CMake 项目set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wall -std=gnu++0x")
在 MacOS X Lion 下的 CMakeLists.txt 文件中。我已经安装了 XCode 4.2.1。但是编译器失败了:
cd something/src/lib && /usr/bin/c++ -Dlib_ginacra_EXPORTS -Wall -std=gnu++0x -fPIC -o CMakeFiles/lib_ginacra.dir/utilities.cpp.o -c something/src/lib/utilities.cpp
cc1plus: error: unrecognized command line option "-std=gnu++0x"
编译器的版本是:
c++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
最佳答案
GCC 4.2 很古老,但 Apple 没有发布更新的版本。
您可以从 Mac Ports 之类的地方安装现代 GCC(这可能更简单、更快捷),或者按照 http://gcc.gnu.org/wiki/InstallingGCC 中的说明自行构建它。
关于c++ - MacOS 的 "-std=gnu++0x"选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10480654/