How to install gcc 4.2 on a macbook with Xcode 4.2
November 6, 2011 2:09 AM   Subscribe

What is the best way to get gcc-4.2 on my Macbook with Snow Leopard and Xcode 4.2?

Xcode 4.2 no longer ships with gcc. Apparently if you upgrade Xcode to version 4.2 it leaves the gcc from 4.1 around, but I did a new install on a new hard drive, and now no longer have gcc. I am not a C programmer myself, but I have quite a few homebrew packages/python c modules that depend on gcc. I am surprised at how difficult it proves to be to install gcc 4.2 on my macbook.

I followed these steps, but with a different install dmg because I do not have access to the one on apple.com that is linked in the StackOverflow answer (I assume that that is only available to developers who have a paid account with Apple?). That worked, but, afterwards my system was borked. iTunes didn't work correctly anymore, many apps on my iPhone were suddenly "waiting....", and Path Finder (my Finder replacement) stopped working. I tried the solutions on Apple.com for the iTunes problem, nothing worked, and I decided to restore to a Time Machine backup.

So, now I am back to step one (an installation without any Xcode) and I want to do it right this time. I think my best step is to install Xcode 3 from the Snow Leopard CD and then install Xcode 4.2 from the app store. This should move Xcode 3 to /Developer-old and leave the compilers around. I'd hate to leave Xcode 3 around though (my only hard drive is a relatively small SSD so I could use the space). I'm afraid though that if I just delete the Developer-old directory that that will somehow break gcc and I'll be back to square one again.

I did find this osx gcc installer, but that's geared towards people who don't want Xcode at all. I also saw some problems with that approach here. That author gives a new approach, but that seems to depend on gcc being installed by Xcode.

So, I'm a bit stumped, and would really like to hear input on what is the best way, with minimum overhead, to install gcc 4.2 on my macbook.
posted by davar to Computers & Internet (16 answers total) 2 users marked this as a favorite
 
Best answer: You should be able to install numerous versions of gcc (including 4.2) using MacPorts.
posted by mkb at 2:14 AM on November 6, 2011 [1 favorite]


You can also get to the Xcode download page with a free Developer account, if you don't want to go the route of the Mac App Store. You should only pay for a Developer account if you want to deploy apps through the two App Stores. If you want to install a newer gcc, follow mkb's suggestion and use MacPorts, which is a command-line package manager like yum or rpm for Linux.
posted by Blazecock Pileon at 2:46 AM on November 6, 2011


Response by poster: The MacPorts website says that it too needs Xcode. Would installing gcc with MacPorts work if I installed Xcode 4.2 (the only available version in the Mac App Store), which only ships with the llvm compiler? It seems that many programs that say they depend on Xcode in fact depend on the gcc that used to be shipped with Xcode. I already have homebrew, so I wouldn't need MacPorts for anything else and am a bit wary of installing another package manager, but if that would work it does sound better than keeping two Xcodes around. I did find someone else on the internet saying after doing some reading around I understand that there might be some issues if I have both of these package managers coexisting. I really need homebrew and my unix tools to continue working as they are.

Blazecock Pileon, I couldn't find an Xcode download page with my free Developer account. It says on the website: You must be an iOS or Mac Developer Program member to download Xcode 4 And then on the "Learn more about Programs" page I can choose either IOS or Mac Program, for $99/year. It would be great if I could find a way to install Xcode 4.1, but I don't see it at the moment. I think there used to be a free download for Xcode on the Apple Developer website, but that changed with Xcode 4.
posted by davar at 3:12 AM on November 6, 2011


You're right. It looks like you have to get it through the Mac App Store, now, unless you buy the iOS or Mac Developer accounts.

But it's free through the App Store, right? It is under Lion, but I'm not certain any longer if that's the case in Snow Leopard.

Not sure why you would want to keep Xcode 3 around, unless you need some special target or tools that are from that release.
posted by Blazecock Pileon at 3:37 AM on November 6, 2011


Response by poster: It's $5 for Snow Leopard. But that's not a problem, I already bought it. My problem is that the newest version (the one that is available through the App Store) doesn't ship with gcc anymore and I need gcc for some homebrew formula's and python modules. So, since Xcode 4.2 doesn't ship with gcc, I'd need another way to install that. Installing Xcode 3 would be one way.
posted by davar at 3:47 AM on November 6, 2011


brew install gcc
posted by zippy at 4:06 AM on November 6, 2011 [1 favorite]


I have successfully built gcc 4.4 using MacPorts and XCode 4. Building anything on my system picks up the llvm compiler (albeit with the gcc front-end). Other mailing list activity seems to indicate that bootstrapping gcc with clang is quite possible.
posted by mkb at 4:09 AM on November 6, 2011


Ah, I take back the earlier brew rec - they don't seem to have a formula for gcc
posted by zippy at 4:12 AM on November 6, 2011


The Bootstrapping CC page on the Homebrew wiki might have some additional information, but it doesn't yet have a clear-cut solution.
posted by SemiSophos at 6:57 AM on November 6, 2011


You can get all the older versions of Xcode (including gcc) from Apple's Developer website. For example, Xcode 4.1 for Lion.
Choose Mac Dev Center, then Additional Downloads, then browse to the end of the list of downloads.
posted by blob at 7:45 AM on November 6, 2011


Response by poster: If I go to Apple's Developer website I get to download Xcode 3 for Snow Leopard. It says "Looking for Xcode 4? Learn more", and then I get the page that directs me to the App Store. I can download the Xcode 4.1 for Lion image that blob linked to, but there is no link on the Apple Developer page for me to download Xcode 4.1 for Snow Leopard. In the Stack Overflow question I linked the answerer provided the link for this Snow Leopard image but I cannot access that with my non-paid developer account. I get an "Access Denied" error.

mkb's way seems the most promising for now. But just to be sure: there is no reason to expect that this macports install will interfere with my homebrew install?
posted by davar at 8:45 AM on November 6, 2011


Xcode 4.1 for Snow Leopard
posted by blob at 9:44 AM on November 6, 2011


Um, Xcode 4.2 only runs on Lion. I am running Xcode 4.1 on Snow Leopard and I have gcc version 4.2.1 installed.
posted by wongcorgi at 9:56 AM on November 6, 2011


Response by poster: Thanks blob, but that's the same link as the link I posted and I cannot download it. I get an "access denied" error if I am logged in with my free developer account.

wongcorgi: The current version for Xcode in the Appstore on Snow Leopard is 4.2. And the Mac Appstore is apparently the only way to install Xcode if you don't have a paid developer account.
posted by davar at 10:09 AM on November 6, 2011


Install the Xcode from the App Store, and then fink/ports-install gcc.
posted by Blazecock Pileon at 1:09 PM on November 6, 2011


Response by poster: Thanks everybody. I installed apple-gcc-4.2 with MacPorts and so far it works fine. Homebrew does complain that MacPorts may cause issues, but I haven't run into anything yet.
posted by davar at 3:03 PM on November 12, 2011


« Older My webpage won't update unless I hit the refresh...   |   I'll pass on that role in the Days of Wine and... Newer »
This thread is closed to new comments.