Mountain Lion: Dealing with xcrun

Are you also having troubles compiling stuff on Mountain Lion with the only the Xcode Command Line Tools installed? Well, normally it’s necessary to install Xcode first, then install the Command Line Tools from within Xcode and then do something with xcode-select in the terminal before make get’s access to, for example, gcc. Installing Xcode wastes at least 5GB from my hard drive, so I tried to find a solution to trick OSX into compiling without it.

How does this work?

Xcrun is a program that keeps track of different compilers and dev-environments which are used by Xcode. It’s developed to make our lives easier, but it requires to have Xcode installed. Since Xcode isn’t installed on my system, xcrun can’t run and exits with errors. As far as I’ve seen the syntax to call a compiler in makefiles on OSX is always like xcrun gcc .... So by replacing xcrun with a little shell-script to pass all it’s arguments right through, I could compile my software just fine.

The fix

  • Delete every bit of Xcode
  • Download and install the Xcode Command Line Tools (only 100MB)
  • Replace /usr/bin/xcrun with the little bash-script below