[ACCEPTED]-How to use/install gcc on Mac OS X 10.8 / Xcode 4.4-gcc

Accepted answer
Score: 423

Update:

You can now just run the following command 13 from your terminal:

xcode-select --install

Starting with Xcode 4.3 12 - you must now manually install command 11 line tools from Xcode menu > Preferences > Downloads.

manual install image

Alternatively, there are 10 stand-alone installation packages both for Mountain Lion (10.8) and 9 for Mavericks (10.9).

This package enables UNIX-style development 8 via Terminal by installing command line 7 developer tools, as well as Mac OS X SDK 6 frameworks and headers. Many useful tools are included, such as the Apple LLVM compiler, linker, and Make. If you use Xcode, these 5 tools are also embedded within the Xcode 4 IDE, and can be installed on your system using 3 the Downloads preferences pane within Xcode 2 4.3 and later. This package requires 1 Mac OS X 10.7.3 or later.

Score: 43

I found that after upgrading from Lion my 5 install was failing because it was looking 4 for GCC in /usr/bin/gcc-4.2. Now the default 3 installation path is /usr/bin/gcc.

My error 2 looked like this:

make: /usr/bin/gcc-4.2: No such file or directory

A symlink will sort out 1 the issue:

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
Score: 26

Just paste this into terminal:

export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH

I hope that 1 helps!

Score: 21

pre-1.9.3 Ruby on Mountain Lion

Pre-requisites

Xcode 4.4, 
Xcode Command Line Tools
Homebrew
XQuartz 2.7.2 or later.
rbenv/ruby-build or RVM.

Install GCC

Note, the 7 Xcode Command Line Tools do not include 6 GCC, they include LLVM-GCC. Same-same, but 5 different.

$ brew tap homebrew/dupes
$ brew install apple-gcc42

Add the following to your ~/.profile 4 or equivalent:

export CC=/usr/local/bin/gcc-4.2

And reload your shell before 3 attempting the install commands below.

Install RVM

CFLAGS="-I/opt/X11/include" rvm reinstall ree

Install Ruby

Prefix the install command with CFLAGS="-I/opt/X11/include"

Then 2 to set your new ruby as default:

user$ rvm use 1.9.2 --default

Then check 1 your ruby version:

user$ ruby -v
Score: 13

For users who can download from Apple a build of Xcode, but not the command line tools

An accepted answer to a comparable question suggests kennethreitz / osx-gcc-installer. In 12 that 'OSX GCC Installer' area, the first 11 of two options is pre-built binaries — for 10 Snow Leopard and for Lion, but not for Mountain Lion. Considering 9 what's included, I should not recommend using 8 that project's GCC-10.7-v2.pkg after installing 7 version 4.4 of Xcode on any build of 10.8.

The 6 more relevant option is build your own, with reference 5 to Apple open source for Developer Tools.

Sources for GCC, compatibility with 10.8

Apple Open Source 4 for the most recently published Developer Tools 4.3 is without 3 GCC. The source for GCC in the 4.1 area may be too old for 2 use with 10.8.

GCC home page for the most recent release.

Build status for GCC 4.7 links 1 to results for x86_64-apple-darwin10.8.0 …

Score: 6

Apple provides an .mpkg installer for the Command 4 Line Tools (CLT), but they don't normally 3 expose the link. It includes GCC. You can 2 install it without downloading/installing 1 XCode.

Download Command Line Tools w/ GCC here.

Score: 3

You can compile it yourself with this Makefile. If you 3 want to save yourself 2-5 hours, I created 2 a signed installer package with GCC 4.7.2 1 for Mac OSX Mountain Lion which you can download here.

Score: 1

You can download the installer(.pkg file) lattest 3 version of GCC for Mountain Lion from this 2 site. You simpy need to download and install 1 it.

https://github.com/kennethreitz/osx-gcc-installer/downloads

Score: 1

I'm using OS X 10.9 Mavericks. I only happened 3 to type gcc -v. The system downloaded gcc 2 immediately. Installation completed without 1 Xcode being installed at all. Testing "Hello, world!" works.

More Related questions