Personal tools

WxHaskell/Mac

From HaskellWiki

< WxHaskell(Difference between revisions)
Jump to: navigation, search
(cabal-macosx changed to macosx-app)
(48 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
== Installing on MacOS X ==
 
== 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) ====
+
<ol>
  +
<li> Install the Developer Tools
  +
<li> Install wxWidgets 2.9 by hand
  +
<ul>
  +
<li>If you use the [http://mxcl.github.com/homebrew/ HomeBrew] package manager:
  +
<br><code>brew install wxmac --devel</code>
  +
<br>or on Lion, possibly <code>brew install wxmac --use-llvm --devel</code>
  +
<li>If you use the [http://www.macports.org/ MacPorts] package manager:<br>
  +
<code>
  +
sudo port install wxWidgets-devel +universal
  +
</code>
  +
<li>Manual installation is not recommended, but if you want to do it anyway, download the source code and install it with the following flags
  +
<pre>
  +
./configure --enable-unicode --disable-debug --with-osx_cocoa
  +
--prefix=/usr/local --enable-stc --enable-aui
  +
--enable-propgrid --enable-xrc --enable-ribbon
  +
--enable-richtext --enable-webkit --with-opengl
  +
make && make install
  +
</pre>
  +
</ul>
  +
<li> (OS X 10.6 or below) Check your path to make sure you are using your wxWidgets and not the default Mac one. The command
  +
<br>
  +
<code>which wx-config</code>
  +
<br>should ''not'' return the file path <code>/usr/bin/wx-config</code>.
  +
<li>Now it's time to install the wxHaskell libraries proper:
  +
<br>
  +
<code>cabal install wx cabal-macosx</code>
  +
<li>Compile and run a [https://raw.github.com/jodonoghue/wxHaskell/master/samples/wxcore/HelloWorld.hs sample wxcore application]:
  +
<br><pre>ghc --make HelloWorld.hs
  +
macosx-app HelloWorld
  +
./HelloWorld.app/Contents/MacOS/HelloWorld
  +
</pre>(see note 2012-04-24-MacPorts if you use MacPorts)
  +
</li>
  +
</ol>
   
# 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>)
+
== Known working configurations ==
# 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].
+
{|
  +
!|Date
  +
!|Arch
  +
!|OS/XCode
  +
!|GHC
  +
!|Haskell Platform
  +
!|wxWidgets
  +
!|wxHaskell
  +
|-
  +
|2012-04
  +
|Intel 64-bit
  +
|Lion (10.7.3), XCode 4.3
  +
|7.4.1
  +
|
  +
|2.9.3 (HomeBrew)
  +
|0.90 (see notes)
  +
|-
  +
|2012-04
  +
|Intel 64-bit
  +
|Lion (10.7.3), Xcode 4.3
  +
|7.0.4
  +
|2011.4.0.0
  +
|2.9.3 (HomeBrew)
  +
|0.90
  +
|-
  +
|2012-04
  +
|Intel 32-bit
  +
|Snow Leopard (10.6.8), Xcode 3.2.6
  +
|7.0.4
  +
|2011.4.0.0
  +
|2.9.3 (MacPorts)
  +
|0.90 (see notes)
  +
|-
  +
|2012-11
  +
|Intel 64-bit
  +
|Mountain Lion (10.8.2), Xcode 4.5.2
  +
|7.4.2
  +
|2012.4.0.0
  +
|2.9.4
  +
|0.90.0.1 (see notes)
  +
|-
  +
|2013-03
  +
|Intel 64-bit
  +
|Mountain Lion (10.8.3), Xcode 4.6.1
  +
|7.4.2
  +
|2012.4.0.0 (64)
  +
|2.9.4
  +
|0.90.0.1
  +
|}
   
==== MacIntel, Leopard (10.5.6), GHC 6.10.1, wxWidgets 2.8.9, wxHaskell 0.10.6 (hackage) ====
+
== Notes ==
   
built on 2008-12-22
+
These notes tend to be a bit ephemeral and are thus dated to help you figure out if they may still apply or not.
# 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].
+
* 2012-04-24 MacPorts: If you use MacPorts, you may run into a problem with the iconv library. Tell GHC that you prefer the system libraries first: <code>ghc HelloWorld.hs -L/usr/lib</code>
  +
* 2012-04-17: The MacPorts version of wxWidgets 2.9.3 can be used. I added a few flags to the Portfile, but they are probably not necessary.
  +
* 2012-04-14: On MacOS X Lion, to install wxWidgets 2.9 with HomeBrew, you may need to run <code>brew install wxmac --use-llvm --devel</code>
   
 
== Using wxHaskell on MacOS X platforms ==
 
== 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.
+
Even though graphical applications on MacOS X look great, it is a still a developers nightmare to get them working :-). This page describes how to circumvent some of the pitfalls.
 
   
 
<ul>
 
<ul>
<li>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.</li>
+
<li>Executables generated with GHC do not work when executed directly if they use the graphical API; they need to be upgraded into so called [https://en.wikipedia.org/wiki/Application_Bundle application bundles] for MacOS X. Use the [https://github.com/gimbo/cabal-macosx cabal-macosx] package to automate this. It can be integrated with Cabal and/or used as a standalone <code>macosx-app</code> script.
<li><p>Haskell applications need the <tt>readline</tt> library which is not installed by default on the MacOS X. [http://www.cs.uu.nl/people/arthurb Arthur Baars] provided a simple [http://wxhaskell.sourceforge.net/download/Readline4.3.dmg installer for the readline library].</p>
+
</li>
<p>Graphical applications generated with GHC do not work if executed directly – they need to be upgraded into MacOS X ''applications''. The <tt>macosx-app</tt> script does this for you. It is provided with binary releases and resides in the <tt>bin</tt> directory of a source release. Creating a program now consists of the following steps:</p>
+
<li><p>''Note: The following no longer applies to <code>wxcore >= 0.90.0.1</code>.''</p>
<pre>&gt; cd samples/wx
+
<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>
&gt; ghc -package wx -o helloworld HelloWorld.hs
 
&gt; /usr/local/wxhaskell/bin/macosx-app -v helloworld
 
&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>
 
 
<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>
Line 35: Line 35:
 
*Main&gt; main</pre>
 
*Main&gt; main</pre>
 
</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>
+
</ul>
  +
  +
== Troubleshooting ==
  +
  +
See [[../Troubleshooting]] for help getting your wxhaskell applications running
  +
  +
<ul><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>
 
<pre>&gt; setenv DYLD_LIBRARY_PATH /usr/local/wxhaskell/lib</pre>
   
 
or
 
or
   
<pre>&gt; setenv DYLD_LIBRARY_PATH $HOME/.cabal/local/lib/wxhaskell-0.11.0/lib</pre></li></li></ul>
+
<pre>&gt; setenv DYLD_LIBRARY_PATH $HOME/.cabal/local/lib/wxhaskell-0.11.0/lib</pre>
   
== Troubleshooting ==
+
or (MacOSX Lion tested only)
  +
  +
Copy (and patch) shared libraries into the app bundle using macosx-make-standalone [http://hackage.haskell.org/package/macosx-make-standalone]
  +
  +
</li></li></ul>
   
See [[../Troubleshooting]] for help getting your wxhaskell applications running
 
   
 
[[Category:wxHaskell|MacOS X]]
 
[[Category:wxHaskell|MacOS X]]

Revision as of 10:46, 20 March 2013

Contents

1 Installing on MacOS X

  1. Install the Developer Tools
  2. Install wxWidgets 2.9 by hand
    • If you use the HomeBrew package manager:
      brew install wxmac --devel
      or on Lion, possibly brew install wxmac --use-llvm --devel
    • If you use the MacPorts package manager:
      sudo port install wxWidgets-devel +universal
    • Manual installation is not recommended, but if you want to do it anyway, download the source code and install it with the following flags
       ./configure --enable-unicode --disable-debug --with-osx_cocoa
                   --prefix=/usr/local --enable-stc --enable-aui
                   --enable-propgrid --enable-xrc --enable-ribbon
                   --enable-richtext --enable-webkit --with-opengl
       make && make install
      
  3. (OS X 10.6 or below) Check your path to make sure you are using your wxWidgets and not the default Mac one. The command
    which wx-config
    should not return the file path /usr/bin/wx-config.
  4. Now it's time to install the wxHaskell libraries proper:
    cabal install wx cabal-macosx
  5. Compile and run a sample wxcore application:
    ghc --make HelloWorld.hs
    macosx-app HelloWorld
    ./HelloWorld.app/Contents/MacOS/HelloWorld
    
    (see note 2012-04-24-MacPorts if you use MacPorts)

2 Known working configurations

Date Arch OS/XCode GHC Haskell Platform wxWidgets wxHaskell
2012-04 Intel 64-bit Lion (10.7.3), XCode 4.3 7.4.1 2.9.3 (HomeBrew) 0.90 (see notes)
2012-04 Intel 64-bit Lion (10.7.3), Xcode 4.3 7.0.4 2011.4.0.0 2.9.3 (HomeBrew) 0.90
2012-04 Intel 32-bit Snow Leopard (10.6.8), Xcode 3.2.6 7.0.4 2011.4.0.0 2.9.3 (MacPorts) 0.90 (see notes)
2012-11 Intel 64-bit Mountain Lion (10.8.2), Xcode 4.5.2 7.4.2 2012.4.0.0 2.9.4 0.90.0.1 (see notes)
2013-03 Intel 64-bit Mountain Lion (10.8.3), Xcode 4.6.1 7.4.2 2012.4.0.0 (64) 2.9.4 0.90.0.1

3 Notes

These notes tend to be a bit ephemeral and are thus dated to help you figure out if they may still apply or not.

  • 2012-04-24 MacPorts: If you use MacPorts, you may run into a problem with the iconv library. Tell GHC that you prefer the system libraries first: ghc HelloWorld.hs -L/usr/lib
  • 2012-04-17: The MacPorts version of wxWidgets 2.9.3 can be used. I added a few flags to the Portfile, but they are probably not necessary.
  • 2012-04-14: On MacOS X Lion, to install wxWidgets 2.9 with HomeBrew, you may need to run brew install wxmac --use-llvm --devel

4 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 :-). This page describes how to circumvent some of the pitfalls.

  • Executables generated with GHC do not work when executed directly if they use the graphical API; they need to be upgraded into so called application bundles for MacOS X. Use the cabal-macosx package to automate this. It can be integrated with Cabal and/or used as a standalone macosx-app script.
  • Note: The following no longer applies to wxcore >= 0.90.0.1.

    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

5 Troubleshooting

See WxHaskell/Troubleshooting for help getting your wxhaskell applications running

  • 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

    or (MacOSX Lion tested only)

    Copy (and patch) shared libraries into the app bundle using macosx-make-standalone [1]