首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用M1 MacBook Pro和cmake编译错误

用M1 MacBook Pro和cmake编译错误
EN

Stack Overflow用户
提问于 2020-12-13 13:20:46
回答 1查看 7.8K关注 0票数 7

我刚刚得到了我的新的M1 MacBook Pro,并且正在试图编译我的大学工作所需的代码库。以下是我所采取的步骤:

Rosetta.

  • Installed brew install cmake

  • Run

  • I将终端设置为始终打开,使用brew install cmake

  • Run cmake <path to source> (工作正常)

  • 运行make (失败)H 214G 215安装了cmake >g 215

下面是我遇到的错误:

代码语言:javascript
运行
复制
/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时,我会得到以下错误:

代码语言:javascript
运行
复制
    -- 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程序),就会得到以下错误:

代码语言:javascript
运行
复制
test.c:1:10: fatal error: 'stdio.h' file not found
#include "stdio.h"

但是使用cc test.c,一切都很好。(运行usr/bin/cc)。

在我看来,Xcode可能有问题。有没有人有类似的问题,或者能给我一些建议?我会很感激的。

EN

Stack Overflow用户

回答已采纳

发布于 2020-12-13 15:32:57

安装xcode后,是否重新打开终端?需要设置环境变量SDKROOT

关闭并再次运行终端或在终端中打开一个新选项卡。

或在当前终端中运行以下命令

代码语言:javascript
运行
复制
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)

还请确保选择了正确的xcode工具链。

代码语言:javascript
运行
复制
# list available xcode toolchains
xcode-select -p

# select one of listed above
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
票数 7
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65276102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档