WxHaskell/Mac: Difference between revisions
m (→Notes) |
No edit summary |
||
Line 63: | Line 63: | ||
These notes tend to be a bit ephemeral and are thus dated to help you figure out if they may still apply or not. | 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-17: The MacPorts version of wxWidgets 2.9.3 can be used | * 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> | * 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 :-) | 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>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 | <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> | </li> | ||
<li><p>''Note: The following no longer applies to | <li><p>''Note: The following no longer applies to <code>wxcore >= 0.90.0.1</code>.''</p> | ||
<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> | <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>> enableGUI >> main</pre> | <pre>> enableGUI >> main</pre> | ||
Line 90: | Line 89: | ||
*Main> main</pre> | *Main> 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>> setenv DYLD_LIBRARY_PATH /usr/local/wxhaskell/lib</pre> | <pre>> setenv DYLD_LIBRARY_PATH /usr/local/wxhaskell/lib</pre> | ||
Line 96: | Line 101: | ||
<pre>> setenv DYLD_LIBRARY_PATH $HOME/.cabal/local/lib/wxhaskell-0.11.0/lib</pre></li></li></ul> | <pre>> 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 14:37, 6 June 2012
Installing on MacOS X
- Install the Developer Tools
- Install wxWidgets 2.9 by hand
- If you use HomeBrew:
brew install wxmac --devel
or on Lion, possiblybrew install wxmac --use-llvm --devel
) - If you use MacPorts:
sudo port install wxWidgets-devel +universal
- If you use HomeBrew:
- Check your path to make sure you are using your wxWidgets and not the default Mac one
-
cabal install wx cabal-macosx
- Compile and run a sample wxcore application:
ghc --make HelloWorld.hs cabal-macosx HelloWorld ./HelloWorld.app/Contents/MacOS/HelloWorld
(see note 2012-04-24-MacPorts if you use MacPorts)
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) |
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
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
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