Installing GCC on OS X Yosemite via Homebrew

Last week I decided to install Mac OS X Yosemite (v10.10), and as expected a lot of things changed under the hood on Mac OS, so things are still not as easy to install as they were on my Mavericks installation.

Almost all of the problems I faced so far I was able to find articles on how to solve them, but when I was trying to install [fswatch]( "Cross-platform file change monitor" "_blank") I had a problem with the GCC compiler.

After digging a bit on Homebrew's GitHub Issues I found that you can edit the GCC formula and apply a patch that will make it work on Yosemite.

The Error

When Homebrew was installing the Bootstrap (make bootstrap) the following error was presented on my terminal:

config.status: executing default commands
make[1]: *** [stage2-bubble] Error 2
make: *** [bootstrap] Error 2


These open issues may also help:
gcc: compatibility 10.10 (
gcc 4.8.3 bottle has invalid omp.h header (
MacOS.(gcc|clang|llvm)_version can return nil (


It's easy do resolve the issue, you only need:

brew edit gcc

Then you will find the following:

   require "formula"

    class Gcc < Formula
        def arch
            if Hardware::CPU.type == :intel
                if MacOS.prefer_64_bit?
            elsif Hardware::CPU.type == :ppc
                if MacOS.prefer_64_bit?

        def osmajor
            `uname -r`.chomp

Then add the code below the osmajor method definition:

        # edit by b.nelissen 20140805
        # tobinjones patch gcc
       patch do
            url ""
            sha1 "def0cb036a255175db86f106e2bb9dd66d19b702"

Now you will need to run brew install gcc again and you should be good to go.

Discussions — 8 Responses

  • Sujeet September 2, 2014 on 11:54 am

    brew gcc edit -> brew edit gcc

  • Ian Douglas February 27, 2015 on 1:54 am

    I've tried this and yet my brew config still throws up the error as follows:

    couldn't understand kern.osversion `14.1.0'

    I'm not sure why the first entry appears twice but output from 'which -a gcc' follows: $ which -a gcc /usr/local/bin/gcc /usr/local/bin/gcc /usr/bin/gcc

    /usr/local/bin shows the following:

    ls -l /usr/local/bin/gcc* lrwxr-xr-x 1 ian admin 55 26 Feb 22:07 /usr/local/bin/gcc -> /Applications// lrwxr-xr-x 1 ian admin 46 26 Feb 20:43 /usr/local/bin/gcc-4.2 -> ../Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 lrwxr-xr-x 1 ian admin 33 24 Feb 22:06 /usr/local/bin/gcc-4.9 -> ../Cellar/gcc/4.9.2_1/bin/gcc-4.9 lrwxr-xr-x 1 ian admin 36 24 Feb 22:06 /usr/local/bin/gcc-ar-4.9 -> ../Cellar/gcc/4.9.2_1/bin/gcc-ar-4.9 lrwxr-xr-x 1 ian admin 36 24 Feb 22:06 /usr/local/bin/gcc-nm-4.9 -> ../Cellar/gcc/4.9.2_1/bin/gcc-nm-4.9 lrwxr-xr-x 1 ian admin 40 24 Feb 22:06 /usr/local/bin/gcc-ranlib-4.9 -> ../Cellar/gcc/4.9.2_1/bin/gcc-ranlib-4.9

    Any idea how to clear the "couldn't understand kern.osversion `14.1.0'" ?

    • Gustavo Bordoni Ian Douglas February 27, 2015 on 5:58 pm

      Hi Ian,

      I would go for removing the xCode version of your GCC which might be still installed.

      Checkout this Issue on HomeBrew, and I would also recommend you to create a Issue there if you having an issue hard to solve.

      What were you trying to accomplish when installing the GCC. The error you are seen is not the same as I had, so the solution above (on the post) won't work.

  • Patricia May 7, 2015 on 4:26 am

    Hi! (Warning, I'm a total newb) I'm trying to get opencv on my mac (yosemite) and get the exact same error as you when it tries to install gcc. I tried to follow your instructions but it doesn't seem to be working.... Now, when I type in brew edit gcc, I get: blablabla
    if MacOS.prefer_64_bit? "powerpc64" else "powerpc" end end end

    def osmajor uname -r.chomp end

    patch do url "" sha1 "def0cb036a255175db86f106e2bb9dd66d19b702" end

    which is what it should be, right? Then, if I type in brew install gcc, I get: Error: You must `brew link gmp' before gcc can be installed

    Did I do something wrong? Could anyone please help me with this?

    Thanks a lot!! P

    • Gustavo Bordoni Patricia May 18, 2015 on 5:08 pm

      Hi Patricia,

      I would say the following, this tutorial is for Beta users of the Yosemite, so if you are having this issue with the opencv, you should open a Ticket on the Official GitHub of the HomeBrew project, just make sure you read the guidelines on how to do it, otherwise people won't be able to help you.

      My best bet to solve your problem would be to fully remove the GCC and then install it again.

      My Best Regards,

  • Michelle September 13, 2015 on 8:26 pm

    Thank you!

  • Matt September 17, 2015 on 5:45 pm

    Hello, still getting the following error when trying to compile with gcc $ make cc -o assign1 assign1.c pslibrary.c pslibrary.h clang: error: cannot specify -o when generating multiple output files make: *** [assign1] Error 1

    Thanks in advance!


Leave a Reply