Home > Mac, Programming, Xcode > Getting gcc 4.2 to work with Xcode 4.2

Getting gcc 4.2 to work with Xcode 4.2

Apparently, gcc 4.2 is no longer installed with Xcode (as of Xcode 4.2). Unfortunately, older projects may need to be compiled with gcc. There is some scattered information online about how to get gcc 4.2 with Xcode 4.2, but they seem complex and error-prone (e.g. install Xcode 4.1, then upgrade to 4.2).

UPDATE: Here are some situations you might find yourself in:

  • Upgrading from Snow Leopard to Lion – it seems that gcc et al will be moved to a different location. See here for a fix.
  • Upgrading to Xcode 4.2 – gcc 4.2 should still be on your machine; you just have to tell Xcode 4.2 to list it as an option (in which case, skip to step #2 below)
  • Installing Xcode 4.2 with no previous version – no gcc 4.2 at all; follow instructions below.

Here’s an easy way to get gcc 4.2 working [1]:
1) Install gcc 4.2. via Mac Ports:

sudo port install apple-gcc42

2) Tweak Xcode so that gcc 4.2 appears as a compiler option, by editing the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options:

  • Open the xcspec file for editing:
sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec"
  • Change lines 41 and 42 from this:

ShowInCompilerSelectionPopup = NO;
IsNoLongerSupported = YES;

To This:

ShowInCompilerSelectionPopup = YES;
IsNoLongerSupported = NO;

  •  Link the gcc 4.2 binary to the location that Xcode expects
sudo ln -s /opt/local/bin/gcc-apple-4.2 /Developer/usr/bin/gcc-4.2
sudo ln -s /opt/local/bin/g++-apple-4.2 /Developer/usr/bin/g++-4.2

[1] Adapted from this Stack Overflow thread

Categories: Mac, Programming, Xcode Tags:

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip
\n