tags:

views:

135

answers:

5

How do i compile a .c file on my mac?

+1  A: 

Use the gcc compiler. This assumes that you have the developer tools installed.

tvanfosson
+7  A: 

You will need to install the Apple Developer Tools. Once you have done that, the easiest thing is to either use the Xcode IDE or use gcc from the command line.

According to Apple's site, the latest version of Xcode (3.2.1) only runs on Snow Leopard (10.6) so if you have an earlier version of OS X you will need to use an older version of Xcode. Your Mac should have come with a Developer Tools DVD which will contain a version that should run on your system. Also, the Apple Developer Tools site still has older versions available for download. Xcode 3.1.4 should run on Leopard (10.5).

Adam Batkin
I went on apples site and they only had Xcode for snow lepord. which i don't have. Where can i find an ealeir version of Xcode on their site? or will the version they have up work for me?
David
Answer updated with further details
Adam Batkin
A: 

You could try using gcc. Instructions are here: http://www.tech-recipes.com/rx/726/mac-os-x-install-gcc-compiler/

Michael Todd
+5  A: 

You can use gcc, in Terminal, by doing gcc -c tat.c -o tst

however, it doesn't come installed by default. You have to install the XCode package from tour install disc or download from http://developer.apple.com

Here is where to download past developer tools from, which includes XCode 3.1, 3.0, 2.5 ...

http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.3.3.3.1

AlBlue
I went on apples site and they only had Xcode for snow lepord. which i don't have. Where can i find an ealeir version of Xcode on their site? or will the version they have up work for me?
David
You should be able to find an older version there as well, not just the Snow Leopard one. If not, it might be on your install DVD in the "Extras" folder which corresponds to your OS. I believe XCode 3.0 was compatible with Leopard, and possibly 3.1 as well.
AlBlue
Added URL to the Apple Connect site where archived XCodes are available.
AlBlue
+1  A: 

You'll need to get a compiler. The easiest way is probably to install XCode development environment from the CDs/DVDs you got with your Mac, which will give you gcc. Then you should be able compile it like

gcc -o mybinaryfile mysourcefile.c
OndraSej
what would those DVD's say on them. i have two. one is a start up disk i think and the other says aplications on it.
David
@David: I'm not a mac user, but since you're trying to install some applications, you might try the one that says applications. (And if I'm wrong, well, try the other one)
Jefromi
I'd bet it's on the Applications CD. I only have the snow Leopard upgrade DVD (and that's just a single DVD), and XCode is in "Optional Installs/Xcode.mpkg"
OndraSej