我刚刚拿到了新的 M1 MacBook Pro,正在尝试编译大学工作所需的代码库。以下是我已采取的步骤:
- 我使用 Rosetta 将终端设置为始终打开。
- 安装的自制程序
using /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- 使用安装的cmake
brew install cmake
- Run
cmake <path to source>
(这很好用)
- Run
make
(这失败了)
这是我得到的错误:
/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 和命令行工具,但无济于事。
使用 cmake gui 应用程序时,我收到不同的错误。我将其设置为使用 CommandLineTools/SDKs/MacOsX11.0.sdk。
跑步时make
使用此 cmake gui 设置生成并配置构建文件后,我收到此错误:
-- 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 world 程序)我收到此错误:
test.c:1:10: fatal error: 'stdio.h' file not found
#include "stdio.h"
但使用cc test.c
一切正常。 (这运行 usr/bin/cc)。
在我看来,Xcode 可能存在问题。有人遇到过类似的问题或者可以给我一些建议吗?我们将不胜感激。