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
](https://github.com/alandipert/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
READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting
These open issues may also help:
gcc: compatibility 10.10 (https://github.com/Homebrew/homebrew/pull/31466)
gcc 4.8.3 bottle has invalid omp.h header (https://github.com/Homebrew/homebrew/issues/29670)
MacOS.(gcc|clang|llvm)_version can return nil (https://github.com/Homebrew/homebrew/issues/18781)
Solution
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?
"x86_64"
else
"i686"
end
elsif Hardware::CPU.type == :ppc
if MacOS.prefer_64_bit?
"powerpc64"
else
"powerpc"
end
end
end
def osmajor
`uname -r`.chomp
end
Then add the code below the osmajor
method definition:
# edit by b.nelissen 20140805
# tobinjones patch gcc https://github.com/Homebrew/homebrew/issues/29845
patch do
url "https://gcc.gnu.org/bugzilla/attachment.cgi?id=33180"
sha1 "def0cb036a255175db86f106e2bb9dd66d19b702"
end
Now you will need to run brew install gcc
again and you should be good to go.