致命错误:limits.h:没有这样的文件或目录
问题描述:
在OSX上,当我使用外部提供的编译器(例如gcc-4.8)时,无法从命令行编译简单程序。不能找到像 limits.h
这样的系统标题。
On OSX, I can't compile simple programs from the command-line when I use an externally-provided compiler (e.g. gcc-4.8). System headers like limits.h
cannot be found.
错误消息示例:
fatal error: limits.h: No such file or directory
或者:
Or:
fatal error: stdio.h: No such file or directory
等等。
有什么不对?
答
请确保您安装了xcode命令行工具:
Make sure you've installed the xcode command-line tools:
xcode-select --install
(接受弹出对话框。)
这会将系统标头安装到gcc等工具预期的标准位置。 / usr / include
。
That will install system headers into standard locations expected by tools like gcc, e.g. /usr/include
.