Personal tools

WxHaskell/Mac

From HaskellWiki

< WxHaskell(Difference between revisions)
Jump to: navigation, search
(Using wxHaskell on MacOS X platforms)
m
Line 1: Line 1:
 
== Installing on MacOS X ==
 
== Installing on MacOS X ==
   
==== Mac (Intel and PowerPC), Tiger (10.4.11), GHC 6.8.2, wxWidgets 2.6.4, wxHaskell 0.10.3 (binary) ====
+
==== Mac (Intel and PowerPC), Leopard (10.5.6), GHC 6.10.1, wxWidgets 2.8.9, wxHaskell 0.11.0 (binary) ====
   
# Download and install wxWidgets for mac ([http://prdownloads.sourceforge.net/wxwindows/wxMac-2.6.4.tar.gz wxMac 2.6.4]) from http://www.wxwidgets.org/ (make sure you configure with <code>--enable-unicode</code>)
+
# 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=586065 sourceforge]
+
# 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
 
# Open the dmg, double-click the .pkg file
   
For more detailed information, see [http://biolpc22.york.ac.uk/pub/2.6.4/install-mac-2.6.4.txt Installing wxWidgets 2.6.4 on Mac OS X] or [http://biolpc22.york.ac.uk/pub/2.6.4/install-cocoa-2.6.4.txt Installing wxWidgets on wxCocoa].
+
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, Tiger (10.4.11, XCode 2.5), GHC 6.8.2, wxWidgets 2.6.4, wxHaskell 0.10.2 (hackage) ====
+
==== MacIntel, Leopard (10.5.6), GHC 6.10.1, wxWidgets 2.8.9, wxHaskell 0.10.6 (hackage) ====
   
built on 2008-02-16
+
built on 2008-12-22
# Download and install wxWidgets for mac ([http://prdownloads.sourceforge.net/wxwindows/wxMac-2.6.4.tar.gz wxMac 2.6.4]) from http://www.wxwidgets.org/
+
# 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 --disable-monolithic --enable-display --enable-unicode --with-opengl --with-mac --without-odbc --enable-mediactrl && make && sudo make install</code>
 
#* I changed into the wxMac topdirectory and used: <code>./configure --disable-monolithic --enable-display --enable-unicode --with-opengl --with-mac --without-odbc --enable-mediactrl && make && sudo make install</code>
 
#* <code>sudo mkdir -p /usr/local/wxhaskell/bin</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 ln -s /usr/local/bin/wx-config /usr/local/wxhaskell/bin</code>
# <code>sudo cabal install wx-core</code>
+
# <code>sudo cabal install wxcore</code>
 
# <code>cabal install wx</code>
 
# <code>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>
   
* Does wxWidgets 2.8.0 work at all? [yes! in the darcs version of wxhaskell as of 2008-04-25]
+
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].
 
Again, for more detailed information, see [http://biolpc22.york.ac.uk/pub/2.6.4/install-mac-2.6.4.txt Installing wxWidgets 2.6.4 on Mac OS X] or [http://biolpc22.york.ac.uk/pub/2.6.4/install-cocoa-2.6.4.txt Installing wxWidgets on wxCocoa].
 
   
 
== Using wxHaskell on MacOS X platforms ==
 
== Using wxHaskell on MacOS X platforms ==
Line 39: Line 39:
 
<pre>&gt; enableGUI &gt;&gt; main</pre>
 
<pre>&gt; enableGUI &gt;&gt; main</pre>
 
<p>Compiling and using enableGUI needs some command line flags:</p>
 
<p>Compiling and using enableGUI needs some command line flags:</p>
<pre>&gt; ghc -ffi -c EnableGUI.hs
+
<pre>&gt; ghc -XForeignFunctionInterface -c EnableGUI.hs
 
&gt; ghci -framework Carbon HelloWorld.hs
 
&gt; ghci -framework Carbon HelloWorld.hs
 
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
 
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Line 51: Line 51:
 
</li>
 
</li>
 
<li><p>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:</p>
 
<li><p>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:</p>
<pre>&gt; setenv DYLD_LIBRARY_PATH /usr/local/wxhaskell/lib</pre></li></ul>
+
<pre>&gt; setenv DYLD_LIBRARY_PATH /usr/local/wxhaskell/lib</pre>
  +
  +
or
  +
  +
<pre>&gt; setenv DYLD_LIBRARY_PATH $HOME/.cabal/local/lib/wxhaskell-0.11.0/lib</pre></li></li></ul>
   
 
[[Category:wxHaskell|MacOS X]]
 
[[Category:wxHaskell|MacOS X]]

Revision as of 10:10, 1 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 --disable-monolithic --enable-display --enable-unicode --with-opengl --with-mac --without-odbc --enable-mediactrl && 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. 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
  • 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