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

Solution 1:

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.

Solution 2:

For me adding the following path to CPATH solved the issue:

export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include