在 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
导致的。
这可能与一个旧问题有关,在升级到Mojave后无法在Mac上编译C程序。
我尝试了建议的解决方案:
- 使用
(sudo) rm -rf /Library/Developer/CommandLineTools
删除整个CommandLineTools
文件夹,并重新安装它xcode-select --install
- 使用
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
安装macOS_SDK_headers_for_macOS_10.14
- 重新安装
brew
和gcc
(也包括gcc@9
和gcc@8
)
但以上方法都没有奏效。