Last Updated: February 25, 2016
·
19.01K
· pcrawfor

Installing gcc on Mavericks

With Mavericks Apple has removed gcc from the command line developer tools (it is now clang just symlinked to gcc).

In order to get the go 1.1.2 source to compile I had to install gcc on my Mavericks machine, since it was failing with clang.

Here's what I did to get it working

First I installed gcc via homebrew:

# installing gcc on mavericks using brew
brew tap homebrew/dupes
brew install apple-gcc42

Then I symlinked the newly installed apple-gcc42 into my /usr/bin folder

cd /usr/bin
sudo mv gcc gcc_mavs
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 gcc

9 Responses
Add your response

The gcc on my machine works fine. Did you try downloading the command line tools before doing this. They took it out of Xcode. Run xcode-select --install on the command line to install them.

over 1 year ago ·

Hi, Ya I did actually install that but was still just getting the clang symlink for gcc. I've had inconsistencies with xcode related xcrun stuff and gcc before though.

over 1 year ago ·

Thanks for your post!!! I tried to follow your instruction, but still got the following error message...Could you help me further?

llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c fun.c -o fun.o
make[1]: llvm-gcc-4.2: No such file or directory
make[1]: *** [fun.o] Error 1
make: *** [fun] Error 1

over 1 year ago ·

Thanks a lot! This really helped me.

I had messed up my symlinks for GCC and had some trouble getting them back in order.

over 1 year ago ·

Thanks! I've only tried it on OSX 10.8 yet, but I expect it to work for me on 10.9 also. Now I can build 32-bit PicoLisp again. (64-bit PicoLisp is a tougher problem. I've never been able to do that on Mac.)

over 1 year ago ·

Another useful note is that you can set the environment variable CC to determine which C compiler software will use (use absolute paths to the executables if using custom software location). For instance, when using gcc-4.8 installed via Homebrew, add this to your shell profile:

export CC=/usr/local/bin/gcc-4.8 # set GCC as global C compiler

over 1 year ago ·

I used this to install ruby 1.9.3 with rvm (which required me to install gcc46), and it worked like a charm. Thank you kind sir.

over 1 year ago ·

Thanks man ! It worked on Marvericks 10.9.4

over 1 year ago ·

This absolutely worked for me on 10.10 Yosemite! Thank you very much!

over 1 year ago ·