After installing Xcode 4.3.1 on OS X Lion, I have lost my GCC compiler. I need this for my study. Does anyone know how I will install this? All I have been able to find was people suggesting to install Xcode 4.3.1 but with the latest Xcode build, Apple has moved the GCC compiler inside the Xcode.app and it doesn't seem to be the same version of the GCC compiler as the one bundled with previous versions of Xcode.
Install Command Line Tools (in Xcode: Preferences > Downloads > Components; or you can go to Apple and download them separately if you don't have/want Xcode installed) - this installs a
gcc command, but it's actually clang
Install Homebrew (instructions), a package manager for OS X
Then, install the 'dupes' homebrew repository and from it the genuine GCC 4.2 compiler:
brew update brew tap homebrew/homebrew-dupes brew install apple-gcc42
/usr/bin/gcc will still be
/usr/local/bin/gcc-4.2 will be
i686-apple-darwin11-gcc-4.2.1 (and associated tools,
g++-4.2 and so forth, also in
Then, you can use whatever mechanism your build process uses (for instance, setting the CC and CXX environment variables appropriately) to select those compilers rather than the clang versions.
I don't use Xcode 4.3 for actual Xcode Projects, only for command line source compilation, and had the same issue. You can bring back your gcc and cc commands with the below commands from terminal:
cd /usr/bin rm cc gcc c++ g++ ln -s gcc-4.2 cc ln -s gcc-4.2 gcc ln -s c++-4.2 c++ ln -s g++-4.2 g++
This will make system wide changes, so be sure that's what you want before doing it.
For these commands to work you'll also need the Command Line Tools for Xcode to be installed, if you don't already have them installed. The Tools can be installed through Xcode's downloads preference pane.