I wanted to compile a little test program I wrote in C. The problem is that, in order to compile on a Mac using the command line, you need to configure the XCode command line tools. You can find this information on the web easily, but I couldn’t get the thing working properly.

In my case, I had XCode installed and at some point I used to have the command lines tools. Then I updated to Mavericks (OSX 9). So gcc could not find the standard libc includes.

amoran@Cuzco:~/dev/test-rdl$ gcc -o test test.c
test.c:1:19: error: stdio.h: No such file or directory

I found out there is a tool called xcode-select that should be able to “print or change the path to the active developer directory”. I didn’t understand exactly what it is for (I suspect it is to handle several Xcode versions), but it looked like the tool I was looking for. In the end the solution was just to reinstall the Xcode command line tools, by using an undocumented option:

xcode-select --install

Once you finish installing, you can use gcc as in any standard Linux box.