tags:

views:

2600

answers:

6

Is there a small, free C or C++ compiler for OS X, like TCC?

Xcode is not small, or simple like TCC, AFAIK.

I'm looking for something like a GCC binary file or TCC for OS X.

+28  A: 

gcc is the most widely used one (and Apple provides official builds of it as part of XCode). XCode is also usually distributed on your OS X cd's, though that version may be a little out of date now, depending on what version of OS X you have.

For information and samples on how to use it, look here.

Look into Fink or one of the similar projects out there if you want a build of gcc that's not linked to Xcode. That said though, Xcode is a great IDE for OS X.

Matthew Scharley
It comes with Xcode.
Daniel A. White
If you install XCode, you can then use gcc directly from the command line if you want...
Ben Gotow
+3  A: 

You could use the Xcode Tools that are already included in OSX.

Xcode is the same professional developer toolset used by Apple to create Mac OS X, as well as many great Apple applications, and Xcode is included with every copy of Mac OS X.

Louis Davis
+3  A: 

You can use Code::Blocks IDE its simple slick and hav good set of feture, a plus opensurce and ready to dl for 3 major plateforms

still recoment using Xcode if u just have to make projects for MAC, but if u are going to port it to linux and windows, then my choice is Code::Blocks [Give it a try atleast]

Agito
A: 

If you don't want to use Xcode install the macports from macports.org and if you like a graphical user interface install porticus as a managment gui for all the installed ports. In Porticus you can now easily install all different versions of gcc without Xcode. Porticus will compile the packages for your mac and install all the needed dependencies like a Linux packet manager.

Janusz
You can't install MacPorts unless you have installed Xcode. So Porticus is not really an alternative to Xcode.
Telemachus
Yes you are right :) MacPorts depends on the Xcode compiler even if you install another version of gcc it will be compiled with the Xcode compiler. My fault
Janusz
+2  A: 

I know you want a small compiler, but it is best to just download and install Xcode. It is a great IDE. From there, you don't have to use it if you don't want to. Once it is installed, you can use something like this in terminal:

gcc myFile.c -o myFile

And that would build a source file called myFile.c which contains C code and the output module (executable) would be myFile. You'd execute it by running:

./myFile

Update: What is your reason for not wanting Xcode? Furthermore, is GCC itself ok (disregarding Xcode for a moment)? It's important to know that GCC is not a part of Xcode. Apple made use of GCC, which is an open source C/C++ (and more) compiler.

I just can't find binaries of GCC for mac so downloading Xcode is an easy way to get some...

Update 2: It also just came to my attention that NetBeans will compile C / C++ Code. It also uses the GCC compiler. I'm not sure if it using GCC from my Xcode installation but I thought I'd mention this.

Best Regards,
Frank

Frank V
Encouragement is not preaching. He didn't post a reason for not using Xcode. Furthermore, I'm suggesting Xcode to get GCC and then showing how to USE gcc to compile. GCC is NOT Xcode. Xcode USES GCC.
Frank V
I've been using Xcode for a while. It's nice, but I don't know that I'd call it a "great" IDE. It has some funkiness to it. Good point that Xcode gives you gcc, but Xcode seems like a lot to grab just to get gcc. Maybe it's the safest way to get gcc, though. Apple will always make sure that there's a solid gcc installed.
Nosredna
More importantly, if you want to develop for OS X, sooner or later you'll have to write some Objective-C code, and that will have to be compiled by the Apple GCC. The only easy way to get a working installation of Apple's GCC is to install XCode, even if you later delete the IDE itself.
+1  A: 

PCC, the Portable C Compiler, is available for the Mac. It is small and free. Its tarball weighs in at total of 1778 KB from its 4th of July CVS Snapshot.

Pratik
I don't see a Mac binary for PCC on that page; am I missing it? If there isn't one, we are back to the Catch 22: the OP first has to install Xcode and gcc in order to compile a smaller compiler.
Telemachus
Yeah, you have to compile it with gcc.
Pratik