Getting gcc on a Mac – oh the pain!
Someone came to visit me today with a MATLAB mex problem and, among other things, I needed to install gcc for them. Now on a Linux machine this would have been trivial. Something like
yum install gcc
or
apt-get install gcc
would do the trick, depending on which flavour of Linux you are using. One command, a quick download and you’re done. Couldn’t be simpler.
I am as green as grass when it comes to Mac usage and so I assumed that there would be some Mac equivalent to these commands but it seems that this is not the case (please please correct me if I am wrong). As far as I can tell, one needs to install something called Xcode in order to get gcc which is 1 Gigabyte in size. You heard me right – 1GB….for gcc! Of course it isn’t just gcc taking up that 1GB – you get lots of other gubbins too – but I don’t want all of the other gubbins. I just want gcc.
But the size isn’t the worst bit. It turns out that you have to go through a registration process in order to get your hands on XCode – giving Apple information such as your email address, home address, what area you work in, what you are going to use XCode for etc etc
All this to get hold of one of the most fundamental open-source applications there is. There has to be a better way. If anyone can enlighten me as to what that better way might be I would be very grateful.
I’ve been using OS X for a year and a half now and I’ve yet to find an alternative to Xcode in order to get gcc on the system. I think part of the problem is that Apple modify GCC to work with their various frameworks (I forget the term they use for them, but it’s something like that). I found this out while I was playing with their bluetooth API.
As far as I can tell, Xcode is the only way to get gcc onto a Mac and retain full functionality (i.e. being able to compile code that uses some mysterious Apple framework). That 1GB of space is a fairly hefty price to pay for the privilege of being able to compile, though.
Perhaps installing Xcode, compiling the vanilla GCC sources using it, then removing Xcode, might work… but that’s a lot of hassle for something so simple, and I’m not even sure it’d work in the end.
Thanks for the post about my Fourier Transformed Tiger, by the way. Your blog is now in my bookmarks since it seems we’re writing about similar things!
Annoying isn’t it? And, as I recently discovered, you don’t even get a Fortran compiler, despite the fact that Fortran is a standard part of gcc.
Hi,
I use Macitoshes since long time, although I have not a good experience as unix user.
To use “apt-get”, you may have a look at “Fink” (http://www.finkproject.org/), but I don’t guarantee it does what you want.
What I am sure, is that you can install gcc and use it on the mac without using Xcode!
You need to install the “programming packages”, that are not in the default installation of MacOS X, but are in the installation DVD (and you can download from the apple website.. you have to register as a developer, but should be free).
The issues with Xcode vs the terminal as a compiling environment are mainly about “environment variables” (is this the correct name.. ?) I mean: the default places where the compiler looks for things, but when you fix these, it works.
About the Fortran compiler, it seems true (it doesn’t come with gcc) but you find good resources here:
http://hpc.sourceforge.net/
MacResearch.org
I am sorry I am not so precise, but I am in a hurry. I can give you details via email.
Cheers
Fabio
It would be faster if you just install linux on that mac computer :-D.
And it would take less space too …
I just found out that Xcode is supplied with the Mac OS X install disc, that might be helpful because you skip all the signing up, or downloading process. It helped me.
Would you like to install just the gcc instead of all of xcode ? If thats what you were looking for, i think the “packages” folder on you leopard “Installation Disk 2” has gcc4.0 package using which one can just install gcc.
It does, but when I run that installer separately, I only get some stuff in /usr/lib, but no gcc in /usr/bin! Is there a GCC binary installed, did it just skip some aliases, or is it simply incomplete?
@Ingemar
One more thing…
At closer inspection, I found that GCC was there, I just had to do
cd /usr/bin
sudo ln gcc-4.0 gcc
and I have GCC. BUT, I don’t get “as”, the assembler. Without that I can’t do much. It seems to be in “DeveloperToolsCLI.pkg”. Is that free software?
Apple is moving away from GCC. This year WWDC Developer videos Apple specially emphasized the move to LLVM for ALL Mac, iPhone and iPad codes.
if you have macports installed you can just do “sudo port install gcc” thats it.
>> if you have macports installed you can just do “sudo port install gcc” thats it.
However, Xcode is a requirement for macports isn’t it? :)