Difference between revisions of "WxHaskell/Mac"

From HaskellWiki
Jump to navigation Jump to search
(replace obsolote MacOS X install instructions)
Line 1: Line 1:
 
== Installing on MacOS X ==
 
== Installing on MacOS X ==
   
  +
1. Install wxWidgets 2.8 by hand (eg. via MacPorts)
==== Mac (Intel and PowerPC), Leopard (10.5.6), GHC 6.10.1, wxWidgets 2.8.9, wxHaskell 0.11.0 (binary) ====
 
 
2. cabal install wx
 
# Download and install wxWidgets for mac ([http://prdownloads.sourceforge.net/wxwindows/wxMac-2.8.9.tar.gz wxMac 2.8.9]) from http://www.wxwidgets.org/ (make sure you configure with <code>--enable-unicode</code>)
 
# Download the wxhaskell binary from [http://sourceforge.net/project/showfiles.php?group_id=73133&package_id=73173&release_id=649115 sourceforge]
 
# Open the dmg, double-click the .pkg file
 
 
For more detailed information, see [http://biolpc22.york.ac.uk/pub/2.8.9/install-mac-2.8.9.txt Installing wxWidgets 2.8.9 on Mac OS X] or [http://biolpc22.york.ac.uk/pub/2.8.9/install-cocoa-2.8.9.txt 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
 
# Download and install wxWidgets for mac ([http://prdownloads.sourceforge.net/wxwindows/wxMac-2.8.9.tar.gz wxMac 2.8.9]) from http://www.wxwidgets.org/
 
#* I changed into the wxMac topdirectory and used: <code>./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</code>
 
#* <code>sudo mkdir -p /usr/local/wxhaskell/bin</code>
 
#* <code>sudo ln -s /usr/local/bin/wx-config /usr/local/wxhaskell/bin</code>
 
# <code>sudo cabal install wxcore</code>
 
# <code>sudo cabal install wx</code>
 
* 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 <code>macosx-app</code> on the programs you have built before you can manipulate the windows that program puts up. This installation process puts it in <code>/usr/local/wxhaskell/bin/macosx-app</code>
 
 
Again, for more detailed information, see [http://biolpc22.york.ac.uk/pub/2.8.9/install-mac-2.8.9.txt Installing wxWidgets 2.8.9 on Mac OS X] or [http://biolpc22.york.ac.uk/pub/2.8.9/install-cocoa-2.8.9.txt Installing wxWidgets on wxCocoa].
 
   
 
== Using wxHaskell on MacOS X platforms ==
 
== Using wxHaskell on MacOS X platforms ==

Revision as of 12:21, 24 November 2009

Installing on MacOS X

1. Install wxWidgets 2.8 by hand (eg. via MacPorts) 2. cabal install wx

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.