Personal tools

WxHaskell/Mac

From HaskellWiki

< WxHaskell
Revision as of 10:08, 9 November 2008 by Apfelmus (Talk | contribs)

Jump to: navigation, search

Contents

1 Installing on MacOS X

1.1 Mac (Intel and PowerPC), Tiger (10.4.11), GHC 6.8.2, wxWidgets 2.6.4, wxHaskell 0.10.3 (binary)

  1. Download and install wxWidgets for mac (wxMac 2.6.4) from http://www.wxwidgets.org/ (make sure you configure with --enable-unicode)
  2. Download the wxhaskell binary from sourceforge
  3. Open the dmg, double-click the .pkg file

For more detailed information, see Installing wxWidgets 2.6.4 on Mac OS X or Installing wxWidgets on wxCocoa.

1.2 MacIntel, Tiger (10.4.11, XCode 2.5), GHC 6.8.2, wxWidgets 2.6.4, wxHaskell 0.10.2 (hackage)

built on 2008-02-16

  1. Download and install wxWidgets for mac (wxMac 2.6.4) from http://www.wxwidgets.org/
    • I changed into the wxMac topdirectory and used: ./configure --disable-monolithic --enable-display --enable-unicode --with-opengl --with-mac --without-odbc --enable-mediactrl && make && sudo make install
    • sudo mkdir -p /usr/local/wxhaskell/bin
    • sudo ln -s /usr/local/bin/wx-config /usr/local/wxhaskell/bin
  2. sudo cabal install wx-core
  3. cabal install wx
  • Enjoy. The TimeFlows and BoucingBalls examples still suffer from not having a correct default background color. This should not affect you too much: just explicitly set the background color.
    • Note that you need to run macosx-app on the programs you have built before you can manipulate the windows that program puts up. This installation process puts it in /usr/local/wxhaskell/bin/macosx-app
  • Does wxWidgets 2.8.0 work at all? [yes! in the darcs version of wxhaskell as of 2008-04-25]

Again, for more detailed information, see Installing wxWidgets 2.6.4 on Mac OS X or Installing wxWidgets on wxCocoa.

2 Using wxHaskell on MacOS X platforms

Even though graphical applications on MacOS X look great, it is a still a developers nightmare to get them working :-). Furthermore, the MacOS X port of wxWidgets is the least mature and still has some quirks. This page describes how to circumvent some of the pitfalls.


  • The installation of wxWidgets provided with OSX Tiger will not work, as it does not have the wxThread symbols that wxHaskell does want to link against.
  • Haskell applications need the readline library which is not installed by default on the MacOS X. Arthur Baars provided a simple installer for the readline library.

    Graphical applications generated with GHC do not work if executed directly – they need to be upgraded into MacOS X applications. The macosx-app script does this for you. It is provided with binary releases and resides in the bin directory of a source release. Creating a program now consists of the following steps:

    > cd samples/wx
    > ghc -package wx -o helloworld HelloWorld.hs
    > /usr/local/wxhaskell/bin/macosx-app -v helloworld
    > open helloworld
  • Due to complicated MacOS X restrictions, graphical wxHaskell applications do not work directly when used from GHCi. Fortunately, Wolfgang Thaller has kindly provided an ingenious Haskell module that solves this problem. Just import the (compiled) module EnableGUI in your program and issue the following command to run main from your GHCi prompt:

    > enableGUI >> main

    Compiling and using enableGUI needs some command line flags:

    > ghc -ffi -c EnableGUI.hs
    > ghci -framework Carbon HelloWorld.hs
    GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
    Loading package base ... linking ... done.
    Loading object (framework) Carbon ... done
    final link ... done
    [2 of 2] Compiling Main             ( Main.hs, interpreted )
    Ok, modules loaded: Main, EnableGUI.
    *Main> enableGUI
    *Main> main
  • The dynamic link libraries used by wxHaskell can not always be found. If your application seems to start (the icon bounces) but terminates mysteriously, you need to set the dynamic link library search path to the wxHaskell library directory. For example:

    > setenv DYLD_LIBRARY_PATH /usr/local/wxhaskell/lib