在macOS Mojave 10.14.6(18G7016(上,gcc
再也找不到文件_ctermid.h
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:90,
from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/cwchar:44,
from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/bits/postypes.h:40,
from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/bits/char_traits.h:40,
from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/string:40,
from /Users/Projects/test.h:10,
from /Users/Projects/test.cpp:1:
/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include-fixed/stdio.h:219:10: fatal error: _ctermid.h: No such file or directory
219 | #include <_ctermid.h>
这可能是由macOS软件更新或brew upgrade
引起的。
这可能与一个旧问题有关。升级到莫哈韦后,无法在Mac上编译C程序。
我尝试了建议的解决方案:
- 使用
(sudo) rm -rf /Library/Developer/CommandLineTools
删除整个CommandLineTools
文件夹并重新安装xcode-select --install
- 将
macOS_SDK_headers_for_macOS_10.14
与open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
一起安装 - 重新安装
brew
和gcc
(以及gcc@9
和gcc@8
(
它们都不起作用。
由于某些原因,xcode-select --install
没有安装macOS 10.14(Mojave(的最新命令行工具。
它总是安装Xcode 10的版本。
要解决此问题,请下载并安装Xcode 11.3.1的命令行工具。这是仍然适用于Mojave的CLT的最新版本。
如果上面的直接链接不起作用,请转到"苹果开发者的更多下载",使用苹果开发者帐户登录,并搜索"Xcode 11.3.1的命令行工具"。请注意,这不是最新版本的CLT,但不能在Mojave上安装更新版本。