Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
    
Note that from Xcode 5 Xcode and command line tools don't include gcc or a wrapper just clang –  Mark Jan 29 at 16:16
add comment

3 Answers

up vote 23 down vote accepted

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.

share|improve this answer
1  
I wish I'd know you could install them separately, I never would have wasted the space downloading and installing Xcode. Thanks! –  Jeff Welling Mar 23 '12 at 18:43
    
I know exactly what you mean. I spend a lot of time working on a Mac Book Air. Xcode uses up a significant portion of my disk. –  Chris Harrison Jul 25 '13 at 5:25
add comment

If the command-line tools are all you need and you don’t really need Xcode, then there’s a much more efficient way to install these tools that doesn’t require you to download multiple gigabytes of data.

Simply download the “Command Line Tools” package from Apple Developer (free account required; you can use your Apple ID). As of this writing, the package is named “Command Line Tools for Xcode - Late March 2012”. It’s a 171.70 MB disk image, which pales in contrast to the 4+ GB Xcode download.

Note that, if you’ve already installed Xcode, you’ll want to uninstall it before installing the Command Line Tools.

share|improve this answer
add comment

This is the expected behaviour, Xcode now uses LLVM as the default compiler. Starting with Xcode 4.3 gcc is not included anymore, distributed builds is not available anymore either.

If you want gcc you will have to download the separate package named "Command Line Tools for Xcode" from Xcode as described in this answer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.