4

On macOS Mojave 10.14.6 (18G7016), gcc can't find the file _ctermid.h anymore

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>

This was either caused by a macOS software update or brew upgrade.

This is might be related to an older question Can't compile C program on a Mac after upgrade to Mojave.

I tried the suggested solutions:

  • deleting the whole CommandLineTools folder with (sudo) rm -rf /Library/Developer/CommandLineTools and reinstalled it xcode-select --install
  • installed the macOS_SDK_headers_for_macOS_10.14 with open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
  • reinstalled brew and gcc (also gcc@9 and gcc@8)

None of them worked.

M. Heuer
  • 395
  • 3
  • 13
  • `brew doctor` says: ```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``` The latter is what I did already. – M. Heuer Jan 11 '21 at 22:47

1 Answers1

5

For some reason, xcode-select --install does not install the most recent Command Line Tools for macOS 10.14 (Mojave).

It always installs the version for Xcode 10.

To fix the issue, download and install Command Line Tools for Xcode 11.3.1. That’s the most recent version of the CLT that still work for Mojave.

In case the direct link above doesn’t work, go to “More Downloads for Apple Developers”, log in with an Apple Developer account, and search for “Command Line Tools for Xcode 11.3.1”. Note that this is not the most recent version of the CLT, but more recent versions can’t be installed on Mojave.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214