Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save startling/122c2ca336f5fdc9d90e to your computer and use it in GitHub Desktop.
Save startling/122c2ca336f5fdc9d90e to your computer and use it in GitHub Desktop.

TLDR version, if you have homebrew

xcode-select --install ; brew tap homebrew/versions ;   brew tap homebrew/dupes \
brew install apple-gcc42 ; brew link apple-gcc42 

NB: the xcode-select --install is how you (re)install the mavericks xcode 5 CLI tools, you HAVE to do that. Either way, you should make sure you have CLI tools installed.

NB: apple-gcc42 is quite old, but doesn't require a build from source (so it can work right away). Those who have a bit more patience and want a more modern GCC can use brew install gcc48 or the like (though the build may take a while)

then edit the settings file as follows:

  • type "ghc-pkg list"

  • the first line of the output will be a path like /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/package.conf.d

  • go one directory up to /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/

  • open the settings file.

  • there'll be a line indicating the path to the c compiler. It'll probably say /bin/gcc

  • change that line to /usr/local/bin/gcc-4.8 (or whichever gcc version you brew installed, such as /usr/local/bin/gcc-4.2)

  • you may also want to make sure that the gcc in your PATH points to this gcc. Many tools have calling gcc hard coded in.

  • if you point gcc to your gcc, be sure to also point cc to that gcc, and g++ to the g++ associated with that gcc. (otherwise when you're building a project that uses a mix of c and c++, you'll have really really weird build errors)

one Alternative approach that works with xcode 5 and doesnt need HomeBrew (by @lukexi and Manuel) here http://justtesting.org/post/64947952690/the-glasgow-haskell-compiler-ghc-on-os-x-10-9

another alternative see http://www.haskell.org/pipermail/haskell-cafe/2013-October/111174.html and https://gist.github.com/mzero/7245290 for tools that should work on a stock mac using haskell platform (work courtesy of Mark Lentczner)

NB: both these approaches use Clang, which hits some exotic corner cases in CPP still, along with some build system quirks.

more explanations

to recap -- the fastest way to have a working GHC / haskell platform install is the following. Much faster than the brew install approach, and uses the builds maintained by the official haskell platform folks.

so the total newb supervised install would be like

  1. make sure the person has up to date CLI tools installed

  2. brew install apple-gcc42

(3,optional, just skip to step 4 if you already have GHC)

  1. install GHC or haskell platform etc (either) and make sure you've appropriately fixed up your path. 64 bit build here http://www.haskell.org/platform/mac.html

  2. do my horrible edit your settings file thing to point the compiler to gcc42

(originaly shared here on reddit

the fastest work around is to use brew to build your own copy of GCC

brew install apple-gcc42 is fastest, i've used brew install gcc48

then type "ghc-pkg list"

the first line will be a path like /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/package.conf.d

go one directory up to /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/

then open the settings file.

there'll be a line indicating the path to the c compiler. It'll probably say "/bin/gcc"

change that line to "/usr/local/bin/gcc-4.8" (or whichever gcc version you brew installed, such as "/usr/local/bin/gcc-4.2")

enjoy life, haskell and mavericks/xcode 5.

NB: this is the power user fix. I recommend that most users instead do one of the approaches in http://www.haskell.org/pipermail/haskell-cafe/2013-September/110320.html

(directions for step 4 laid out below in the comments)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment