6

Follow up to the same problem on Mojave.

After upgrading to macOS Catalina, none of the C headers can be found in /usr/include. The reason for this may be found in the Xcode 10 release notes (previous version):

The Command Line Tools package installs the macOS system headers inside the macOS SDK. Software that compiles with the installed tools will search for headers within the macOS SDK provided by either Xcode at:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

or the Command Line Tools at:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

[...] As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided. [...]

(See the link to the question above for details on this suggested workaround.)

Apparently Apple made good on their threat with Xcode 11. How can one install the C headers to /usr/include on macOS Catalina using Xcode 11?

Context: The clang python binding search the header files in /usr/include per default. According to kkurian's answer and the comment I made (in response to this question), there are multiple ways to control this behaviour, if necessary.

Related question: Can't compile C program on a Mac after upgrade to Mojave.

  • You don't - your build system needs to point to the correct path – user151019 Oct 9 at 14:01
  • 1
    Unfortunately, the python bindings for clang don't leave you a lot of choice in that matter... – mkl Oct 9 at 14:17
  • Sounds liks that should be reported as a bug to clang then – user151019 Oct 9 at 18:23
  • The particular problem of using the python bindings in macOS Catalina can be solved by adding the compiler flag -isysroot [...] to the cindex.Index.parse call, where [...] is the return value of xcrun --show-sdk-path. – mkl Oct 13 at 19:50
5

Set the CPATH environment variable in your shell (e.g., put this in your .zshrc assuming you're using zsh):

export CPATH=`xcrun --show-sdk-path`/usr/include

And then try to build your project again.

UPDATE

The OP related to how to install the headers in /usr/include, not how to point clang to the headers wherever they may be.

MacOS System Integrity Protection prevents the creation of /usr/include, even by root. See this related answer.

If you disabled SIP (not recommended) then I imagine something like

sudo ln -s `xcrun --show-sdk-path`/usr/include /usr/include

will do the trick.

  • Thanks for answering! This does indeed work with clang's python bindings, and, therefore, solves my problem. For the sake of correctness, I will not accept this answer, since the original question about how to install the C headers to /usr/include remains unanswered. Again, my thanks! – mkl Oct 15 at 8:40
  • Nevermind, clang python brings still have trouble finding some headers, apparently. Anyways, that seems to be the material for a new question. Thanks for helping... – mkl Oct 15 at 8:47
  • 1
    @mkl I've updated the answer. Thank you for your feedback. – kkurian Oct 16 at 7:38
  • Ah, many thanks! I guess this is as close as one can get to writing anything to /usr/include, given that Apple has clearly stated that the workaround mentioned in the question will not be available in future versions of Xcode... – mkl Oct 16 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .