Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 821
Jonathan Leffler Avatar asked Oct 07 '19 23:10

Jonathan Leffler


People also ask

Can you compile C on Mac?

C code can be written in any platform like Mac, Windows, etc. C compilers compile C code and create an executable according to the platform. The executable created for one platform can only be executed on that platform.

Is macOS 10.15 Catalina still supported?

If Apple follows the same "unofficial" plan that they have been following, Catalina support will end sometime after WWDC 2022.

Are there any problems with macOS Catalina?

However, no operating system is without issues, and Catalina is no exception. While typical installation and performance problems shouldn't come as a surprise, macOS 10.15. 7 still has some quirks that may need addressing.


1 Answers

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.

like image 172
Roy Avatar answered Nov 05 '22 19:11

Roy