Skip to content

Instantly share code, notes, and snippets.

@jonathanjouty
Forked from kowey/gist:2420144
Created July 10, 2012 21:01
Show Gist options
  • Save jonathanjouty/3086205 to your computer and use it in GitHub Desktop.
Save jonathanjouty/3086205 to your computer and use it in GitHub Desktop.
Haskell GTK on 64 bit MacOS X

Notes

  • on lion (and snow leopard i suppose), make sure you are using a 64 bit install of ghc. Also, unless you are suggesting an edit to these directions, please go ask people on the relevant mailing list or wiki for help :)
  • Tested on Mac OS X 10.7.4, GHC 7.4.1, 64bit Haskell Platform 2012.2.0.0 (installer package) with Command Line Tools for XCode (June 2012).
  • These notes were originally brought to you by Carter Schonwald; the “I” probably refers to him. Eric Kow will refer to himself in the third person).
  • Forked from kowey (Eric Kow): https://gist.github.com/2420144

Steps

  1. Install gtk and cairo via HomeBrew

    brew install glib cairo gtk gettext fontconfig
    brew deps gtk # see below
    brew deps gtk | xargs brew link
    brew link cairo gettext fontconfig
    gtk-demo # just to see what happens
    

    Brew may complain, who cares, this makes your life easier (at least if you're living in a haskell world :p )

    NOTE: you will need to make sure that all these Brew libs are built, and linked in

  2. Download libfreetype

  3. Unpack libfreetype, and then run

    brew install stow
    mkdir /usr/local/stow
    ./configure --prefix /usr/local/stow/freetype-2.4.8
    make
    make install
    cd /usr/local/stow
    stow freetype-2.4.8
    

    This will install the static and dynamic library files for lib freetype in /usr/local/ (../include and ../lib) , which is what you'll want, though this will contribute to brew doctor complaining, but again, this is the easiest way. Eric Kow has added stow to this mix because he thinks that making this easily reversible may be a good thing.

  4. Install Haskell gtk

     cabal install gtk2hs-buildtools 
     cabal install gtk
    

    This should work sans complaints! Here if you run into problems installing cairo, you'll see it complains about pkg-config not finding the libpng package in it's search path. First make sure you see libpng.pc in /usr/X11/lib Then

     PKG_CONFIG_PATH=/usr/X11/lib
     export PKG_CONFIG_PATH
     cabal install cairo
     cabal install gtk
    
  5. Install something using Cairo, eg, this plott.hs

     cabal install chart-gtk
     ghc --make plott.hs # see link above
     ./plott
    

    Try out some other cool libraries like diagrams!

More information

  • brew deps gtk on Eric Kow's machine

    $ brew deps gtk
    atk
    cairo
    gdk-pixbuf
    gettext
    glib
    jasper
    jpeg
    libffi
    libtiff
    pango
    pixman
    pkg-config
    xz
            
    $ brew deps gtk | xargs brew link
    Warning: Already linked: /usr/local/Cellar/atk/2.2.0
    Linking /usr/local/Cellar/cairo/1.10.2... 23 symlinks created
    Warning: Already linked: /usr/local/Cellar/gdk-pixbuf/2.24.1
    Linking /usr/local/Cellar/gettext/0.18.1.1... 181 symlinks created
    Warning: Already linked: /usr/local/Cellar/glib/2.30.3
    Warning: Already linked: /usr/local/Cellar/jasper/1.900.1
    Warning: Already linked: /usr/local/Cellar/jpeg/8d
    Linking /usr/local/Cellar/libffi/3.0.11... 9 symlinks created
    Warning: Already linked: /usr/local/Cellar/libtiff/3.9.5
    Warning: Already linked: /usr/local/Cellar/pango/1.28.4
    Warning: Already linked: /usr/local/Cellar/pixman/0.24.4
    Warning: Already linked: /usr/local/Cellar/pkg-config/0.25
    Warning: Already linked: /usr/local/Cellar/xz/5.0.3
    
    $ brew link cairo gettext fontconfig
    Warning: Already linked: /usr/local/Cellar/cairo/1.10.2
    Warning: Already linked: /usr/local/Cellar/gettext/0.18.1.1
    Linking /usr/local/Cellar/fontconfig/2.8.0... 241 symlinks created
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment