Personal tools

WxHaskell/Mac

From HaskellWiki

< WxHaskell(Difference between revisions)
Jump to: navigation, search
m
(open helloworld => open helloworld.app && SUDO cabal install wx)
Line 17: Line 17:
 
#* <code>sudo ln -s /usr/local/bin/wx-config /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 wxcore</code>
# <code>cabal install wx</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.
 
* 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>
 
** 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>
Line 35: Line 35:
 
&gt; ghc -package wx -o helloworld HelloWorld.hs
 
&gt; ghc -package wx -o helloworld HelloWorld.hs
 
&gt; /usr/local/wxhaskell/bin/macosx-app -v helloworld
 
&gt; /usr/local/wxhaskell/bin/macosx-app -v helloworld
&gt; open helloworld</pre></li>
+
&gt; open helloworld.app</pre></li>
 
<li><p>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 [http://wxhaskell.sourceforge.net/download/EnableGUI.hs Haskell module] that solves this problem. Just import the (compiled) module [http://wxhaskell.sourceforge.net/download/EnableGUI.hs <tt>EnableGUI</tt>] in your program and issue the following command to run <tt>main</tt> from your GHCi prompt:</p>
 
<li><p>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 [http://wxhaskell.sourceforge.net/download/EnableGUI.hs Haskell module] that solves this problem. Just import the (compiled) module [http://wxhaskell.sourceforge.net/download/EnableGUI.hs <tt>EnableGUI</tt>] in your program and issue the following command to run <tt>main</tt> from your GHCi prompt:</p>
 
<pre>&gt; enableGUI &gt;&gt; main</pre>
 
<pre>&gt; enableGUI &gt;&gt; main</pre>

Revision as of 10:24, 3 January 2009

Contents

1 Installing on MacOS X

1.1 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.

1.2 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.

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