Difference between revisions of "WxHaskell/Mac"

From HaskellWiki
Jump to navigation Jump to search
Line 60: Line 60:
   
 
See [[../Troubleshooting]] for help getting your wxhaskell applications running
 
See [[../Troubleshooting]] for help getting your wxhaskell applications running
  +
  +
# Why do I have to <code>macosx-app</code> my binaries?
  +
#* 2009-04-01: we don't know for sure yet. <code>macosx-app</code> is just a shell script that runs <code>Rez</code> and also creates an application bundle. If you are a MacOS developer, especially a wxWidgets one, we would love some help answering this question.
   
 
[[Category:wxHaskell|MacOS X]]
 
[[Category:wxHaskell|MacOS X]]

Revision as of 10:51, 1 April 2009

Installing on MacOS X

Mac (Intel and PowerPC), Leopard (10.5.6), GHC 6.10.1, wxWidgets 2.8.9, wxHaskell 0.11.0 (binary)

  1. Download and install wxWidgets for mac (wxMac 2.8.9) 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.8.9 on Mac OS X or Installing wxWidgets on wxCocoa.

MacIntel, Leopard (10.5.6), GHC 6.10.1, wxWidgets 2.8.9, wxHaskell 0.10.6 (hackage)

built on 2008-12-22

  1. Download and install wxWidgets for mac (wxMac 2.8.9) from http://www.wxwidgets.org/
    • I changed into the wxMac topdirectory and used: ./configure --enable-shared --disable-monolithic --enable-display --enable-unicode --with-mac --with-opengl --with-odbc --enable-mediactrl --enable-sound --enable-graphics_ctx && 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 wxcore
  3. sudo 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

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

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.app
  • 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: 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

    or

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

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.