首页 > 解决方案 > Clang 在 OSX 中找不到头文件,系统完整性使我无法移动它们。如何在 Big Sur 中链接它们?

问题描述

在使用 clang 构建一些软件包时,我得到:

 fatal error: 'math.h' file not found
#include <math.h>
         ^~~~~~~~
1 error generated.

我已经安装了命令行工具:

% xcode-select --install 
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

现在,我发现了另一个帖子,他们发现问题在于头文件位于错误的位置。确实可以math.h/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include. 同一篇文章指出系统完整性阻止您将文件移动到/usr/local/include. 然后一些评论者建议使用:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -usr /

或者

sudo installer -allowUntrusted -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

但是我没有该文件macOS_SDK_headers_for_macOS_10.14.pkg(或任何类似文件)。那个包裹不再发货还是我错过了什么?有没有一种合法的方法可以将头文件移动到正确的位置而不必关闭系统完整性?


注意我还了解到/usr/local苹果不再使用它。因此,它们似乎/usr/local/include是这些文件最合适的目标位置,因为我确定它在路径中(正如运行 clang with 所揭示的那样-v)。

标签: xcodemacosclang

解决方案


推荐阅读