Personal tools


From HaskellWiki

< WxHaskell(Difference between revisions)
Jump to: navigation, search
(Installing on MacOS X)
(64 bit (2012-03-07))
Line 6: Line 6:
# <code>cabal install wx</code>
# <code>cabal install wx</code>
== 64 bit (2012-03-07) ==
== Known configurations ==
''Warning: this information may be obsolete by the time you read it, please check with the wxHaskell mailing list for the latest story''
If you are using a 64 bit version of GHC, you will need
* Haskell Platform 2011.4.0.0 (GHC 7.0.4)
* wxWidgets 2.9
* ...with the Cocoa UI (not Carbon, no 64 bit support)
* the wxHaskell branch at
!|Haskell Platform
|Intel 64-bit
|Lion (10.7.3), Xcode 4.3
|2.9.3 (HomeBrew)
== Using wxHaskell on MacOS X platforms ==
== Using wxHaskell on MacOS X platforms ==

Revision as of 10:34, 14 April 2012


1 Installing on MacOS X

  1. Install the Developer Tools
  2. Install wxWidgets 2.9 by hand (HomeBrew makes this easy: brew install wxmac)
  3. Check your path to make sure you are using your wxWidgets and not the default Mac one
  4. cabal install wx

2 Known configurations

Date Arch OS/XCode wxWidgets wxHaskell GHC Haskell Platform
2012-04 Intel 64-bit Lion (10.7.3), Xcode 4.3 2.9.3 (HomeBrew) 0.90 7.0.4 2011.3.0.0

3 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

    If you can't find macosx-app on your system, please refer to the instructions at this Stack Overflow question.

  • 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 -XForeignFunctionInterface -c EnableGUI.hs
    > ghci -framework Carbon HelloWorld.hs
    GHCi, version 6.8.2:  :? 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


    > setenv DYLD_LIBRARY_PATH $HOME/.cabal/local/lib/wxhaskell-0.11.0/lib

4 Troubleshooting

See WxHaskell/Troubleshooting for help getting your wxhaskell applications running

  1. Why do I have to macosx-app my binaries?
    • 2009-04-01: we don't know for sure yet. macosx-app is just a shell script that runs Rez and also creates an application bundle. If you are a MacOS developer, especially a wxWidgets one, we would love some help answering this question.
    • 2009-11-24: Please see also Andy Gimblett's cabal-macosx project