On OSX, I can't compile simple programs from the command-line when I use an externally-provided compiler (e.g. gcc, or a custom clang install). System headers like limits.h
cannot be found.
Example error messages:
fatal error: limits.h: No such file or directory
Or:
fatal error: stdio.h: No such file or directory
Or:
fatal error: 'stdlib.h' file not found
and so on.
What's wrong?
Make sure you've installed the xcode command-line tools:
xcode-select --install
(Accept the pop-up dialog.)
That will install system headers into standard locations expected by tools like gcc, e.g. /usr/include
.
If this doesn't work, it may have to do with the upgrade to macOS 10.14 Mojave
See the answer here for how to resolve:
Can't compile C program on a Mac after upgrade to Mojave
somehow when you install mojave it deletes headers- run:
open/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg