From HaskellWiki
< WxHaskell
Revision as of 13:50, 5 August 2008 by EricKow (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.

  • 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
  • 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