Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: limits.h: No such file or directory

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?

like image 281
Stuart Berg Avatar asked Jun 16 '15 20:06

Stuart Berg


2 Answers

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.

like image 192
Stuart Berg Avatar answered Sep 23 '22 17:09

Stuart Berg


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

like image 37
user2688151 Avatar answered Sep 21 '22 17:09

user2688151