xcode 致命错误:limits.h:没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30877659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
fatal error: limits.h: No such file or directory
提问by Stuart Berg
On OSX, I can't compile simple programs from the command-line when I use an externally-provided compiler (e.g. gcc, or a custom clang install). System headers like limits.h
cannot be found.
在 OSX 上,当我使用外部提供的编译器(例如 gcc 或自定义 clang 安装)时,我无法从命令行编译简单程序。limits.h
找不到类似的系统标头。
Example error messages:
示例错误消息:
fatal error: limits.h: No such file or directory
Or:
或者:
fatal error: stdio.h: No such file or directory
Or:
或者:
fatal error: 'stdlib.h' file not found
and so on.
等等。
What's wrong?
怎么了?
回答by Stuart Berg
Make sure you've installed the xcode command-line tools:
确保你已经安装了 xcode 命令行工具:
xcode-select --install
(Accept the pop-up dialog.)
(接受弹出对话框。)
That will install system headers into standard locations expected by tools like gcc, e.g. /usr/include
.
这会将系统头文件安装到 gcc 等工具预期的标准位置,例如/usr/include
.
回答by user2688151
If this doesn't work, it may have to do with the upgrade to macOS 10.14 Mojave
如果这不起作用,则可能与升级到 macOS 10.14 Mojave 有关
See the answer here for how to resolve:
请参阅此处的答案以了解如何解决:
回答by Hillary Murefu
somehow when you install mojave it deletes headers- run:
当您安装 mojave 时,它会以某种方式删除标题-运行:
open/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
打开/库/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg