【发布时间】:2021-04-16 21:46:30
【问题描述】:
在 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 引起的。
这可能与较早的问题Can't compile C program on a Mac after upgrade to Mojave有关。
我尝试了建议的解决方案:
- 用
(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)
它们都不起作用。
【问题讨论】:
-
brew doctor说:Warning: A newer Command Line Tools release is available. Update them from Software Update in System Preferences or run: softwareupdate --all --install --force If that doesn't show you an update run: sudo rm -rf /Library/Developer/CommandLineTools sudo xcode-select --install后者是我已经做过的。