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 have a Mac with OS X 10.6.8 Snow Leopard. I'm trying very hard to learn the basics of programming in C, but I can't get my first simple program to run. I read online to go to Xcode Preferences -> Downloads and check in there for gcc downloads, but Xcode 3.2.6 doesn't have a Downloads tab in the preferences. I've tried downloading gcc from the gcc.gnu website, but I didn't see anything specifically labeled gcc, and I still couldn't get my simple "Hello, World!" program to run in terminal.

It's very possible this is an easy solution, however I haven't been able to find anything pointing me in he right direction. It's definitely a little convoluted as a beginner, but I'm trying.

Any help would be greatly appreciated. Just a hand to get Xcode and gcc working.

share|improve this question
    
Command Line Tools for Xcode includes this stuff. However they seem to be only available for OS X 10.7.3 or later. Have you thought about upgrading your OS? –  Steven Lu Jul 3 '12 at 4:50
    
Have you gone through the Xcode guide in the help? –  Mark Jul 3 '12 at 10:21

3 Answers 3

As noted by CanuckSkier above you can download the gcc toolchain as a separate download from within XCode or the developer site, or you can invoke the bundled gcc using the xcrun command.

xcrun gcc -v

will give you the version installed.

If you are just wanting to learn C however don't get too hung up on which compiler toolchain you are working with. XCode gives you the option to create a command line tool which you can edit build and run within the IDE which should get you started. You will eventually progress to building and running from the shell if you need to.

share|improve this answer

Xcode 3.2.5 does include gcc.

There is no need to download gcc from gcc.gnu.

To check whether gcc is installed on your machine and gcc is in your shell its search path, do run Terminal command $ which gcc. Our output is: /usr/bin/gcc

When gcc is not in your search path, you can try to find it for example with a Terminal locate command.

Note in our case there are multiple versions of gcc installed: /usr/bin/gcc-4.0 /usr/bin/gcc-4.2

share|improve this answer

You can install the command line tools separately from here. You want the 10.6 download listed under "Option 1: Downloading Pre-Built Binaries".

share|improve this answer

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.