Terminal Xcode Gcc – Ensuring GCC Availability after Xcode Installation

gccterminalxcode

I just got a Mac and I'm a complete newbie, so this may be kind of a really easy question, but I wasn't able to solve it with Google or F1.

I was trying to run a C program from the Terminal that comes with mac, but when I used gcc test.c, it said -bash: gcc: command not found. I looked up the error on Google and discovered that I needed to download Xcode. I did that and installed it (I think, after all it runs), but I still don't have gcc in my Terminal. What can I do?

Best Answer

Great question — this recently changed, so I suspect many other people are wondering the same thing.

In the latest version of Xcode, the command line tools are distributed as a separate package. Luckily they're very easy to install:

  • Open Xcode, and open the Preferences window (+,).
  • Switch to the Downloads tab.
  • Click "Install" (or "Update") next to "Command Line Tools". You can also configure automatic updates, and additional Xcode components.

Note: since these tools are actually a completely separate package, you can install the command line tools without installing Xcode, if you don't need Xcode and want to save some disk space. They can be downloaded separately from the Apple developer site.