Personal tools

WxHaskell/2.8

From HaskellWiki

< WxHaskell(Difference between revisions)
Jump to: navigation, search
(wxHaskell 0.90)
 
m
Line 79: Line 79:
   
 
ChengWei: I've found that if you put wx-config in some system directories, such as c:\windows\system32, 'cabal install wx' will complain "wx-config: does not exist". To put it in another directory in %PATH% will solve this problem. Tested on Windows 7, Haskell platform 2010 2.0.0.0.
 
ChengWei: I've found that if you put wx-config in some system directories, such as c:\windows\system32, 'cabal install wx' will complain "wx-config: does not exist". To put it in another directory in %PATH% will solve this problem. Tested on Windows 7, Haskell platform 2010 2.0.0.0.
  +
  +
=== Detailed Guide to Getting Going with wxPack on Windows ===
  +
  +
==== Installing on Windows ====
  +
  +
Follow [http://www.scribd.com/doc/38034374/20100923-WxHaskell-Setup SkyTreeBird's guide]. It which walks you through the basic steps
  +
  +
* wx-config
  +
* wxPack
  +
* setting up environment variables
  +
* <code>cabal install wx</code>
  +
  +
Note that the best way to refer to WxWidgets in your PATH is probably to use the WXWIN variable that you set, eg. <code>%WXWIN%/lib/gcc_dll</code>
  +
  +
The guide has been tested with the following configurations. Others may work too:
  +
  +
{|border=1 style="border-collapse: collapse;"
  +
! Windows
  +
! Haskell Platform
  +
! wxWidgets
  +
|-
  +
|| XP || 2010.2.0.0 || 2.8.10
  +
|-
  +
|| 7 || 2011.2.0.1 || 2.8.12
  +
|}
  +
  +
==== Troubleshooting Windows installation with cabal ====
  +
  +
These remarks refer to wx-0.13.2 and Haskell Platform 2011.4.0.0 on Windows 7.
  +
  +
Cabal package wx depends on wxcore which depends on wxdirect. By default cabal installs on a per user base, thus wxdirect.exe will be installed to <code>c:\Users\<YOUR NAME>\AppData\Roaming\cabal\bin\</code>. This folder must be in your <code>PATH</code> for <code>cabal install wxcore</code> to succeed.
  +
  +
Package wxcore-0.13.2 does not work well with wx-config revision 21 2006-10-19 (downloaded from [http://sites.google.com/site/wxconfig/ here] on Feb 2<sup>nd</sup> 2012). If <code>cabal install wxcore</code> fails with an output containing "Usage: wx-config [options]" try this:
  +
  +
* <code>cabal unpack wxcore</code>
  +
* <code>cd wxcore-0.13.2</code>
  +
* edit <code>Setup.hs</code> and comment out/remove the line containing <code>"wx-config" ["--version"]</code>
  +
* <code>runhaskell.exe Setup.hs configure --user</code>
  +
* <code>runhaskell.exe Setup.hs build</code>
  +
* <code>runhaskell.exe Setup.hs install</code>
  +
  +
Finally call <code>cabal install wx</code>.

Revision as of 22:08, 13 April 2012

Contents

1 Prerequisites

Ensure you have a recent GHC compiler – version 6.10.3 or higher is recommended. In principle, any Haskell 98 compiler that supports the standard FFI libraries along with cabal install should work, but we typically test new releases only against the latest version of Haskell Platform for the supported targets. We have discontinued support for building without cabal.

  • Windows: You will need wx-config for Windows, MinGW 5.1.6 and MSYS 0.1.11 (these are the latest versions at the time of writing). You must select the C++ compiler option when installing MinGW.
    • MinGW 5.1.6 can be downloaded from MinGW
    • MSYS 0.1.11 can be downloaded from MSYS
    • wx-config can be downloaded from wx-config
  • Mac OS X: you need to install the gcc compiler, which is part of the Apple Developer Tools. These tools are shipped with Panther and are installed by invoking Applications/Installers/Developer Tools/Developer.mdmg.

You should install the current stable version of wxWidgets for your platform - versions older than 2.8.1 are no longer supported. Build instructions are given for Windows - on most other platforms you should be able to obtain wxWidgets using your package manager (you may need -developer packages).

We assume in this guide that the variable $wxwin points to your wxWidgets installation directory, for example: ~/dev/wxGTK-2.8.10.

2 Getting wxWidgets

wxHaskell 0.13.x supports wxWidgets > 2.8.0 and < 2.9.0

  • Windows
    • You can use the wxPack prebuilt binaries (the MinGW ones). This is a highly recommended approach.
    • Alternatively, you can build using the MinGW compiler - instructions below.
  • Mac OS X
    • Tiger - do not use the wxMac 2.5 that comes pre-installed.
    • Leopard - wxHaskell now supports wxWidgets 2.8.
    • Lion - You will need to use wxWidgets 2.9.x and wxHaskell 0.90, as wxWidgets 2.8.x is not 64bit clean.
  • Linux - the wxWidgets that ships with your system (as long as it's the 2.8 one and not the 2.6 one) should work.

See the wxWidgets site for more details.

3 Building wxWidgets (usually optional)

3.1 On Windows

Note: Microsoft compilers are no longer supported. The cabal build system cannot understand the output of wx-config for Microsoft compilers.

Note: The Haskell Platform 2010.1.0.0 installer shipped without C++ support. If you want to build wxHaskell on Windows using this Haskell Platform, please see [1]

Note: At the time of this writing there is a MinGW bug that may prevent you from building wxWidgets. The solution for now is to use tdm-gcc. Check the wxWidgets wiki for details.

Using the MSYS shell, and making sure that you have the C++ compiler option installed for MinGW as it is 'not' the default:

> cd /c/path/to/wxWidgets-2.8.10/build/msw
> mingw32-make -f makefile.gcc BUILD=release SHARED=1 UNICODE=1

This will take quite some time and generate lots of text in the MSYS shell. Assuming it is successful, a DLL is generated in /c/path/to/wxWidgets/gcc_dll, which you will need to copy to a location where it can be found when running your executables.

3.2 On Unix systems

You should follow the instructions on the wxWidgets website if there are no suitable packages for your environment. You should use GCC to build wxWidgets, as this makes it more likely that cabal will understand the output of wx-config.

On most Unix platforms, wxWidgets build goes something like: create a mybuild directory in the wxWidgets directory, and run configure and make from that directory (and take the time to get some coffee :-).

> cd $wxwin
> mkdir mybuild
> cd mybuild
> ../configure --enable-unicode
> make
> make install
> cd ../contrib/src
> make
> make install

3.3 Testing wxWidgets build

Now try out a few samples of wxWidgets to see if it all works correctly:

> cd ../../samples/controls
> make
> ./controls

Note that you build from the local samples directory that resides in the mybuild directory.

And also try if wx-config works too:

> wx-config -v

ChengWei: I've found that if you put wx-config in some system directories, such as c:\windows\system32, 'cabal install wx' will complain "wx-config: does not exist". To put it in another directory in %PATH% will solve this problem. Tested on Windows 7, Haskell platform 2010 2.0.0.0.

4 Detailed Guide to Getting Going with wxPack on Windows

4.1 Installing on Windows

Follow SkyTreeBird's guide. It which walks you through the basic steps

  • wx-config
  • wxPack
  • setting up environment variables
  • cabal install wx

Note that the best way to refer to WxWidgets in your PATH is probably to use the WXWIN variable that you set, eg. %WXWIN%/lib/gcc_dll

The guide has been tested with the following configurations. Others may work too:

Windows Haskell Platform wxWidgets
XP 2010.2.0.0 2.8.10
7 2011.2.0.1 2.8.12

4.2 Troubleshooting Windows installation with cabal

These remarks refer to wx-0.13.2 and Haskell Platform 2011.4.0.0 on Windows 7.

Cabal package wx depends on wxcore which depends on wxdirect. By default cabal installs on a per user base, thus wxdirect.exe will be installed to c:\Users\<YOUR NAME>\AppData\Roaming\cabal\bin\. This folder must be in your PATH for cabal install wxcore to succeed.

Package wxcore-0.13.2 does not work well with wx-config revision 21 2006-10-19 (downloaded from here on Feb 2nd 2012). If cabal install wxcore fails with an output containing "Usage: wx-config [options]" try this:

  • cabal unpack wxcore
  • cd wxcore-0.13.2
  • edit Setup.hs and comment out/remove the line containing "wx-config" ["--version"]
  • runhaskell.exe Setup.hs configure --user
  • runhaskell.exe Setup.hs build
  • runhaskell.exe Setup.hs install

Finally call cabal install wx.