Can't compile a C program on a Mac after upgrading to Catalina 10.15

Jonathan Leffler picture Jonathan Leffler · Oct 8, 2019 · Viewed 38.3k times · Source

There's a previous question Can't compile C program on a Mac after upgrade to Mojave, and the answers to that have covered most of the variations on what goes wrong.

Now — as of Monday 2019-10-07 — you can upgrade to macOS Catalina 10.15. Once again, during the upgrade, the /usr/include directory has been blown away by the update, even though XCode 11.0 was installed before upgrading (from Mojave 10.14.6) to Catalina. Consequently, compilers built to expect that there is a /usr/include directory do not work any longer.

The main recommended step for the Mojave issues — using the command:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

does not work out of the gate because the directory /Library/Developer/CommandLineTools/Packages/ does not exist (so there's not yet a .pkg file to open).

Is there a good (official) way to create and populate the directory /usr/include?

Answer

Roy picture Roy · Oct 12, 2019

Before you proceed, make sure to install xcode command line tools.

xcode-select --install

Actually, you can do it! Actually all the C headers are found here in this folder:

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

We just need to create symlink for all the headers file into this folder:

/usr/local/include/

It worked for me! the following command line will take care of all the problems:

sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/

You will get some warning. Some of the headers already exists, like this:

ln: /usr/local/include//tcl.h: File exists
ln: /usr/local/include//tclDecls.h: File exists
ln: /usr/local/include//tclPlatDecls.h: File exists
ln: /usr/local/include//tclTomMath.h: File exists
ln: /usr/local/include//tclTomMathDecls.h: File exists
ln: /usr/local/include//tk.h: File exists
ln: /usr/local/include//tkDecls.h: File exists
ln: /usr/local/include//tkPlatDecls.h: File exists

totally ok to ignore. that's all.