我刚刚得到了我的新的M1 MacBook Pro,并且正在试图编译我的大学工作所需的代码库。以下是我所采取的步骤:
Rosetta.
brew install cmake
brew install cmake
cmake <path to source>
(工作正常)
make
(失败)H 214G 215
安装了cmake >g 215下面是我遇到的错误:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:97:15: fatal error:
'stdlib.h' file not found
#include_next <stdlib.h>
我已经尝试卸载和重新安装Xcode和CommandLineTools,但没有任何效果。
当使用cmake应用程序时,我会得到一个不同的错误。我将其设置为使用CommandLineTools/SDKs/MacOsX11.0.sdk。
在使用cmake安装程序生成和配置构建文件之后运行make
时,我会得到以下错误:
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - broken
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/freyamurphy/nori/build/ext_build/src/tbb_p-build/CMakeFiles/CMakeTmp
如果我运行命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc test.c
(简单的hello程序),就会得到以下错误:
test.c:1:10: fatal error: 'stdio.h' file not found
#include "stdio.h"
但是使用cc test.c
,一切都很好。(运行usr/bin/cc)。
在我看来,Xcode可能有问题。有没有人有类似的问题,或者能给我一些建议?我会很感激的。
发布于 2020-12-13 15:32:57
安装xcode后,是否重新打开终端?需要设置环境变量SDKROOT
。
关闭并再次运行终端或在终端中打开一个新选项卡。
或在当前终端中运行以下命令
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
还请确保选择了正确的xcode工具链。
# list available xcode toolchains
xcode-select -p
# select one of listed above
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
https://stackoverflow.com/questions/65276102
复制相似问题