Difference between revisions of "WxHaskell/Windows"

From HaskellWiki
Jump to navigation Jump to search
m
 
(111 intermediate revisions by 5 users not shown)
Line 1: Line 1:
=== Building wxWidgets and wxc with Microsoft Visual C++ ===
+
== wxWidgets 3.0 and wxHaskell >= 0.92 ==
   
  +
=== Installing the easy way ===
The advantage of using Visual C++ is that the resulting libraries are smaller and faster than the gnu compiled ones. Furthermore, the debug version provides for automatic detection of memory leaks in the wxWidgets libraries and you get a warning when forgetting to deallocate wxWidgets objects. The drawback is that the configure scripts are not used and you will need to set some options manually.
 
   
  +
The easiest way to install wxHaskell on Windows, is to use a wxInstall package. wxInstall Achelanne contains wxWidgets 3.0, compiled with GCC 5.2.0, the necessary DLLs, and an installation script to install wxHaskell. It is available in 32 bit and in 64 bit and can be used for GHC 7.10.3 and later.
If you want to use Visual C++ Express Edition, you must use Visual C++ 2008 Express Editions or higher. Because previous version requires [http://msdn2.microsoft.com/express/aa700755.aspx installing Microsoft Platform SDK] before building wxWidgets or wxHaskell.
 
   
  +
wxInstall Abriline installs wxWidgets 3.0 together with the latest wxHaskell packages from Hackage and is available for 32 bit GHC, using GCC 4.5.2 and for 64 bit GHC using GCC 4.6.3; this means Abriline can be used (amongst others) for Haskell Platforms 2013.2.0.0, 2014.2.0.0 and 7.10.2, and MinGHC 7.10.1. The Haskell packages are installed locally.
We use the wxWidgets provided workspace directly:
 
   
  +
Installation instructions:
* '''wxWidgets 2.4''': Open the <tt>$wxwin/src/wxWidgets.dsw</tt> workspace. Select menu &quot;<tt>Build/Set active configuration</tt>&quot; and select &quot;<tt>wxWidgets - win32 release unicode</tt>&quot; to build the (static) library. After compilation, you can also select &quot;<tt>wxWidgets - win32 debug unicode</tt>&quot; to build the debug version.
 
* '''wxWidgets 2.6''': Open the <tt>$wxwin/build/msw/wx.dsw</tt> workspace. Select menu &quot;<tt>Build/Batch build</tt>&quot; and select all configurations by using the mouse and the <tt>shift</tt> key, when you click a marker, all configurations are deselected. Next you manually select the &quot;Unicode Release&quot; and &quot;Unicode Debug&quot; versions of all projects and press &quot;Build&quot;. Afterwards, press &quot;Save All&quot; to save all your mouse clicking work :-)
 
If you want to use [http://wxhaskell.sourceforge.net/doc/Graphics.UI.WXCore.Db.html database access] and [http://wxhaskell.sourceforge.net/doc/Graphics.UI.WXCore.OpenGL.html openGL canvas], you must edit <tt>$wxwin/include/msw/setup.h</tt>'s <tt>#define wxUSE_*</tt>(* is target feature name) from 0 to 1.
 
   
  +
* If the most recent wxHaskell packages are already installed, unregister them first (with <code>ghc-pkg unregister &lt;package name&gt;</code>).
After building wxWidgets, you need to run <tt>configure</tt> for the wxHaskell library.
 
   
  +
* Download one of the [http://sourceforge.net/projects/wxhaskell/files/wxInstall/ installation packages] and unzip it to its destination directory.
<pre>&gt; cd $wxhaskell
 
&gt; ./configure --with-msc</pre>
 
If you want to use the debug version of the library, use the <tt>--wxc-libname</tt> option too.
 
   
  +
* Click on Install.bat; the wxHaskell packages will be installed.
<pre>&gt; ./configure --with-msc --wxc-libname=wxcd</pre>
 
After configuration, first run <tt>make</tt> command to generate stc_gen.* files.
 
   
  +
* Adjust your search path as advised by Install.bat
<pre>&gt; make</pre>
 
Make will stop by following error.
 
   
<pre>&gt; make: *** No rule to make target `out/wxc/wxc-msw2.6.4-0.10.1.dll', needed by `wxc'. Stop.</pre>
 
Then go <tt>$wxhaskell/wxc</tt> directory. Here, you need to adapt the <tt>wxc-&lt;em&gt;version&lt;/em&gt;.dsp</tt> project to reference the correct wxWidgets directory. Open the <tt>.dsp</tt> file in an editor and replace all occurrences of &quot;<tt>..\..\wxWindows-2.4.2</tt>&quot; (or &quot;<tt>..\..\wxWindows-2.6.4</tt>&quot;) or by the installed wxWidgets directory, i.e. <tt>$wxwin</tt>.
 
   
  +
To test wxHaskell, install [[wxAsteroids]] with:
After adapting the project file, you can open the workspace <tt>wxc/wxc-&lt;em&gt;version&lt;/em&gt;.dsw</tt> and build the release and debug versions of the C wrapper library (if you use wxWidgets 2.6.4, you must choose &quot;Unicode Release&quot; or &quot;Unicode Debug&quot; instead of choosing just &quot;Release&quot; or &quot;Debug&quot;).
 
  +
<pre>
  +
cabal install wxAsteroids
  +
</pre>
  +
and run it with command <code>wxAsteroids</code> (the directory %APPDATA%\cabal\bin must be in your search path).
   
  +
You can update to a newer version of wxHaskell by running Install.bat
And finally! – you can run <tt>make</tt> in the <tt>$wxhaskell</tt> directory to build the Haskell libraries.
 
  +
again; for a newer version of wxWidgets, a new configuration of this package is needed.
   
  +
=== Installing the hard way ===
<pre>&gt; cd $wxhaskell
 
&gt; make
 
&gt; make install
 
&gt; make wx
 
&gt; make wx-install</pre>
 
   
  +
'''This is something you do if there is no installation package available for your configuration, or you want to modify wxHaskell.'''
== User experiences ==
 
==== GHC 6.8.3, wxWidgets 2.6.4, wxHaskell 0.10.3 (binary) ====
 
   
  +
wxHaskell binds to wxWidgets, so wxWidgets must be installed first.
# Download the wxhaskell binary from [http://sourceforge.net/project/showfiles.php?group_id=73133&package_id=73173&release_id=586065 sourceforge]
 
  +
We will install wxWidgets with the GCC that is packaged with GHC, to prevent incompatibilities between object/archive files.
# Unpack wxhaskell-*.zip. And double-click wxhaskell-*\bin\wxhaskell-register.bat.
 
  +
<br>
# wxhaskell-register.bat install wxHaskell to your system.
 
  +
You need mingw32-make.exe from [http://www.mingw.org/ MinGW] and sh.exe from [http://sourceforge.net/projects/mingw/files/MSYS/ MSYS] in your search path (look for sh.exe in your GHC directory tree). If you do not have it yet, install [http://git-scm.com/ GIT].
  +
Download [https://sourceforge.net/projects/wxhaskell/files/wx-config-win/ wx-config.exe] (a new version for wxWidgets > 3.0) and copy it somewhere into your search path. It is also possible to download [https://github.com/wxHaskell/wxHaskell/tree/master/wx-config-win/wx-config-win the source for wx-config from the official wxHaskell repository]; compile it with
  +
c++ wx-config.cpp -o wx-config
  +
The C++ compiler comes with GHC.
   
==== Assumptions (a.k.a. what I have tested) ====
+
==== Installing wxWidgets ====
   
  +
Install the [http://wxwidgets.org/ wxWidgets source] in C:\Libs\wxWidgets\3.1.1
* GHC 6.4.2 (Jason Dagit reports success with GHC 6.5 as well).
 
  +
<br>
  +
Commands to compile wxWidgets and wxHaskell with Haskell Platform 2014.2.0.0 and later:
  +
<pre>
  +
Set WXWIDGETS_VERSION=3.1.1
  +
Set WXWIN=C:\Libs\wxWidgets\%WXWIDGETS_VERSION%
  +
Cd %WXWIN%\build\msw
  +
</pre>
  +
Edit config.gcc so that the following values are set:
  +
<pre>
  +
SHARED ?= 1
  +
BUILD ?= release
  +
</pre>
  +
If you are using GCC 5.2.0 or later (included with GHC 7.10.3 and later), change CXXFLAGS as well:
  +
<pre>
  +
CXXFLAGS ?= -std=gnu++11 -Wno-deprecated-declarations
  +
</pre>
  +
(Without -Wno-deprecated-declarations, you will get a huge amount of useless 'deprecated' messages.)
  +
If you want to compile 64 bit binaries, set the following as well
  +
(64 bit compilation requires GCC > 4.6, which comes with GHC > 7.10):
  +
<pre>
  +
# Standard flags for CC
  +
CFLAGS ?= -m64
   
  +
# Standard flags for C++
* Cygwin installation. See [http://wxhaskell.sourceforge.net/building-cygwin.html | wxHaskell cygwin page] for detail, but broadly, you need Cygwin bash and install binaries.
 
  +
CXXFLAGS ?= -m64 -std=gnu++11 -Wno-deprecated-declarations
   
  +
# Standard preprocessor flags (common for CC and CXX)
* wxWidgets built/installed in a path with no spaces in it. Actually you can use a path with spaces but there are a few rules. For example, I had ghc installed to this location:<br/><tt>C:\Program Files\Visual Haskell</tt><br/>So this required me to use the following configure command:<br/><tt>./configure --libdir=C:/Progra~1/Visual~1</tt><br/>
 
  +
CPPFLAGS ?= -D_M_AMD64
The two important things here are: 1) You must use the forward slash
 
  +
</pre>
and 2) you cannot use spaces.
 
   
  +
Edit ..\..\include\wx\msw\setup.h, change line 788 (may differ in later versions of wxWidgets, look for the #define for none-_MSC_VER compilers) from
Next I found that I needed to add <tt>C:\Program Files\Visual Haskell</tt> to
 
  +
<pre>
my path so that the wxHaskell dlls could be located by windows.
 
  +
# define wxUSE_GRAPHICS_CONTEXT 0
  +
</pre>
  +
to
  +
<pre>
  +
# define wxUSE_GRAPHICS_CONTEXT 1
  +
</pre>
  +
<br>
  +
Set the environment variables
   
  +
* for Haskell Platform 2014.2.0.0:
* Environment variables:
 
  +
<pre>
** PATH should include MinGW and Cygwin binary directories. MinGW must come before Cygwin in PATH.
 
  +
Set HASKELL_COMPILER_DIR=C:\Program Files\Haskell Platform\2014.2.0.0
** WXHASKELL environment var points to wxHaskell install directory.
 
  +
Set PATH=%HASKELL_COMPILER_DIR%\mingw\libexec\gcc\mingw32\4.5.2\;%HASKELL_COMPILER_DIR%\lib\extralibs\bin;%HASKELL_COMPILER_DIR%\bin;%HASKELL_COMPILER_DIR%\mingw\bin;%path%
** WXWIN environment directory points to wxWidgets install directory.
 
  +
Set LIBRARY_PATH=%HASKELL_COMPILER_DIR%\mingw\lib;%HASKELL_COMPILER_DIR%\mingw\lib\gcc\mingw32\4.5.2;%LIBRARY_PATH%
  +
</pre>
  +
  +
* for Haskell Platform 7.10.2-a:
  +
<pre>
  +
Set HASKELL_COMPILER_DIR=C:\Program Files\Haskell Platform\7.10.2-a
  +
Set Path=%HASKELL_COMPILER_DIR%\lib\extralibs\bin;%HASKELL_COMPILER_DIR%\bin;%HASKELL_COMPILER_DIR%\mingw\bin;%path%
  +
Set LIBRARY_PATH=%WXWIN%\lib\gcc_lib;%HASKELL_COMPILER_DIR%\mingw\lib;%LIBRARY_PATH%
  +
</pre>
  +
Clean and build wxWidgets, using the MinGW shell:
  +
<pre>
  +
sh -c "mingw32-make -f makefile.gcc clean"
  +
sh -c "mingw32-make -f makefile.gcc all"
  +
</pre>
  +
There will be many linker warnings for old versions of GCC, those are solved in a more recent GCC version.
  +
The result is now in %WXWIN%\lib\gcc_dll
  +
  +
If you get a message like
  +
<pre>
  +
'c:/Program' is not recognized as an internal or external command,
  +
</pre>
  +
there is probably a space in the path to an executable. It is better to
  +
install the Haskel Platform in a directory without spaces in the full
  +
name, but there is another solution: use the old fashioned short names, like:
  +
<pre>
  +
Set HASKELL_COMPILER_DIR=C:\PROGRA~1\HASKEL~1\7.10.2-a
  +
</pre>
  +
(Use the MS-DOS command <code>For %i In (ghc.exe) Do Echo %~sdp$PATH:i</code> to see the path to GHC with short names)
  +
<br>
  +
  +
If you get a message about denied access: if you already compiled and
  +
ran a wxHaskell program, the wxWidgets DLLs are loaded and cannot be
  +
overwritten. Restart the computer.
  +
  +
==== Installing wxHaskell ====
  +
  +
Using the environment variables HASKELL_COMPILER_DIR and WXWIN from the previous subsection:
  +
<pre>
  +
Set WXCFG=gcc_dll\mswu
  +
Set CPLUS_INCLUDE_PATH=%HASKELL_COMPILER_DIR%\mingw\lib\gcc\mingw32\4.5.2\include\c++;%WXWIN%\include
  +
Set LIBRARY_PATH=%WXWIN%\lib\gcc_lib;%HASKELL_COMPILER_DIR%\mingw\lib\
  +
</pre>
  +
  +
  +
===== From GitHub =====
  +
  +
You can get wxHaskell from Hackage and from GitHub;
  +
to install the most recent version of wxHaskell from the repository:
  +
<pre>
  +
Cd &lt;Where\you\want\to\install\wxHaskell&gt;
  +
git clone https://github.com/wxHaskell/wxHaskell.git
  +
Cd wxHaskell
  +
cabal install .\wxdirect
  +
cabal install .\wxc
  +
cabal install .\wxcore
  +
cabal install .\wx
  +
</pre>
  +
  +
Make sure that all below mentioned DLLs are in the search path and try a sample program:
  +
<pre>
  +
Cd samples\wxcore
  +
ghc BouncingBalls
  +
BouncingBalls
  +
</pre>
  +
Click with the left mouse button on the window to create new bouncing balls.
  +
  +
If you get an exception code 0xc000007b immediately after starting your wxHaskell program, there is a mismatch between bitness of your program and the bitness of the wxWidgets DLLs. Note, that the package wxc checks the bitness at installation time, but things can go wrong afterwards, like changing the search path to point to a different version of the wxWidgets DLLs.
  +
  +
===== From Hackage =====
  +
  +
To install the wxHaskell from Hackage:
  +
<pre>
  +
cabal install wx
  +
</pre>
  +
  +
== wxWidgets 3.0 and wxHaskell 0.91.x ==
  +
  +
{|border=1 style="border-collapse: collapse;"
  +
! Windows
  +
! Haskell Platform
  +
! wxWidgets
  +
|-
  +
|| 8.1 || 2013.2.0.0 || 3.0.1
  +
|-
  +
|| 8.1 || 2014.2.0.0 || 3.0.1, 3.0.2
  +
|-
  +
|}
  +
  +
  +
Prerequisites:
  +
* If you want to install from Hackage: [http://sourceforge.net/projects/mingw/files/OldFiles/MinGW%205.1.6/ MinGW 5.1.6] and [http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe MSYS 1.0.11] (a recent version of MinGW will result in incompatible DLLs). You must select the C++ compiler and MinGW-make options when installing MinGW. Add the full path to directories MinGW\bin and msys\1.0\bin to your search path. If you install the most recent version from GitHub, use the same version of GCC as the one that comes with GHC (use command <code>gcc --version</code>), to prevent compatibility problems.
  +
  +
  +
Environment variables:
  +
  +
* GHC_VERSION: 7.8.3 (some recent version)
  +
* WXC_VERSION: 0.91.0.0 (preferably the most recent version, see [http://hackage.haskell.org/package/wxc Hackage])
  +
* WXWIN: C:\wxWidgets-3.0.3
  +
* WXCFG: gcc_dll\mswu
  +
* PATH: (add these) %WXWIN%\lib\gcc_dll;%WXWIN%;%APPDATA%\cabal\bin;%APPDATA%\cabal\i386-windows-ghc-%GHC_VERSION%\wxc-%WXC_VERSION%
  +
  +
If you are using a cabal sandbox, you must add the following to your search path:
  +
* .cabal-sandbox\bin
  +
to ensure that wxdirect.exe can be found.
  +
  +
Steps:
  +
  +
<ol>
  +
<li> Make sure, that the GCC from the MinGW package is used for compilation of wxWidgets, by adding its directory to the start of the search path, with a command like:
  +
<pre>
  +
Set path=C:\MinGW\bin;%path%
  +
</pre>
  +
<li> Download [http://wxwidgets.org/downloads wxWidgets 3.0.3 source]
  +
<li> Extract to C:\wxWidgets-3.0.3
  +
<li> [http://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW Build wxWidgets-3.0.3]
  +
<br>Edit <tt>wxwidgets-src-dir\build\msw\config.gcc</tt> so that the following values are set:
  +
<pre>
  +
SHARED ?= 1
  +
BUILD ?= release
  +
</pre>
  +
Then (in cmd.exe, ''not'' bash):
  +
<pre>
  +
cd wxwidgets-src-dir\build\msw
  +
sh
  +
mingw32-make -f makefile.gcc
  +
</pre>
  +
<li> Download [https://sourceforge.net/projects/wxhaskell/files/wx-config-win/ wx-config.exe] (a new version for wxWidgets > 3.0) and copy it somewhere into your search path, for instance via
  +
<pre>
  +
copy wx-config.exe %CABAL_DIR%\bin
  +
</pre>
  +
<li> Make sure, that the GCC that comes with GHC is used for the rest of the procedure, by adding its directory to the search path, with a command like:
  +
<pre>
  +
Set path=C:\Haskell\Haskell Platform\2014.2.0.0\mingw\bin\;%path%
  +
</pre>
  +
<li> Install the wxHaskell libraries</li>
  +
To get the most recent version (using [http://git-scm.com/ Git]):
  +
<pre>
  +
git clone git://github.com/wxHaskell/wxHaskell.git
  +
cd wxHaskell\wxdirect
  +
cabal update
  +
cabal install
  +
cd ..\wxc
  +
cabal install
  +
cd ..\wxcore
  +
cabal install
  +
cd ..\wx
  +
cabal install
  +
</pre>
  +
Or, for the Hackage version:
  +
<pre>
  +
cabal update
  +
cabal install wx
  +
</pre>
  +
Or, if you want to install the dependencies separately:
  +
<pre>
  +
cabal update
  +
cabal install wxdirect
  +
cabal install wxc
  +
cabal install wxcore
  +
cabal install wx
  +
</pre>
  +
<li> Install the DLLs described in the next subsection
  +
</ol>
  +
  +
  +
=== DLLs ===
  +
  +
In order to run a wxHaskell application, Windows must be able to find the following wxWidgets DLLs (see [http://msdn.microsoft.com/en-us/library/7d83bc18(v=vs.71).aspx Search Path Used by Windows to Locate a DLL]):
  +
  +
* wxWidgets-x.y.z\lib\gcc_dll\*.dll
  +
  +
The following file can be found in directory wxc\dist\build\, after building package wxc in directory wxc:
  +
* wxc.dll (be sure to recompile and copy this one when you compile your application with a new compiler)
  +
  +
If you are using GHC 7.10.3 or later, the rest of the necessary DLLs can be found in the mingw\bin directory of your GHC installation. For an earlier GHC, you can find the DLLs in the [http://sourceforge.net/projects/wxhaskell/files/wxInstall/ wxInstall Abriline packages], or as described below.
  +
  +
The following DLLs can be found in directory "Haskell Platform\2014.2.0.0\mingw\bin\", or in ghc-7.10.1\mingw\bin\ if you installed the compiler only (change revision as needed):
  +
* libgcc_s_dw2-1.dll
  +
* libstdc++-6.dll
  +
* mingwm10.dll
  +
  +
Some wxHaskell applications also require the following DLLs:
  +
* uuid.dll
  +
* perl510.dll
  +
* libapr-1.dll
  +
* libapriconv-1.dll
  +
* libaprutil-1.dll
  +
  +
These DLLs can be obtained by installing [http://sourceforge.net/projects/xampp/files/XAMPP%20Windows/1.7.4/ XAMPP 1.7.4]; the DLLs are in the directories:
  +
* xampp\perl\site\lib\auto\APR\UUID
  +
* xampp\perl\bin
  +
* xampp\apache\bin
  +
  +
If there are still DLLs missing, you can find out which, using [http://cygwin.com/cygwin-ug-net/cygcheck.html cygcheck] from the [http://www.cygwin.com/ Cygwin project]. Note, that you will get problems if you have both MinGW and Cygwin in your search path; it is best to specify the full path to cygcheck.exe, or copy cygcheck.exe to some location in the search path.
  +
Sample command:
  +
C:\programs\cygwin\bin\cygcheck.exe .\h.exe
  +
(the .\ must be specified)
  +
  +
== wxWidgets 2.8 and wxHaskell 0.13.x ==
  +
  +
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
  +
|}
  +
  +
  +
=== DLLs ===
  +
  +
In order to run a wxHaskell application, the following DLLs must be in the search path:
  +
  +
* mingwm10.dll; this can be found in directory "Haskell Platform\2012.2.0.0\mingw\bin\", or in ghc-7.4.2\mingw\bin\ if you installed just the compiler (change revision as needed)
  +
  +
* wxmsw28u_gcc_custom.dll
  +
  +
  +
  +
=== Troubleshooting 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>.
   
For more detailed information, see [http://biolpc22.york.ac.uk/pub/2.6.4/install-msw-2.6.4.txt Installing wxWidgets 2.6.4 on Microsoft Windows 9x/ME, Windows NT, Windows 2000, Windows XP, and Windows CE].
 
   
 
== See also ==
 
== See also ==
   
* [[../MSC]]
 
 
* [[../Cygwin]]
 
* [[../Cygwin]]
   

Latest revision as of 23:13, 11 July 2021

wxWidgets 3.0 and wxHaskell >= 0.92

Installing the easy way

The easiest way to install wxHaskell on Windows, is to use a wxInstall package. wxInstall Achelanne contains wxWidgets 3.0, compiled with GCC 5.2.0, the necessary DLLs, and an installation script to install wxHaskell. It is available in 32 bit and in 64 bit and can be used for GHC 7.10.3 and later.

wxInstall Abriline installs wxWidgets 3.0 together with the latest wxHaskell packages from Hackage and is available for 32 bit GHC, using GCC 4.5.2 and for 64 bit GHC using GCC 4.6.3; this means Abriline can be used (amongst others) for Haskell Platforms 2013.2.0.0, 2014.2.0.0 and 7.10.2, and MinGHC 7.10.1. The Haskell packages are installed locally.

Installation instructions:

  • If the most recent wxHaskell packages are already installed, unregister them first (with ghc-pkg unregister <package name>).
  • Click on Install.bat; the wxHaskell packages will be installed.
  • Adjust your search path as advised by Install.bat


To test wxHaskell, install wxAsteroids with:

  cabal install wxAsteroids

and run it with command wxAsteroids (the directory %APPDATA%\cabal\bin must be in your search path).

You can update to a newer version of wxHaskell by running Install.bat again; for a newer version of wxWidgets, a new configuration of this package is needed.

Installing the hard way

This is something you do if there is no installation package available for your configuration, or you want to modify wxHaskell.

wxHaskell binds to wxWidgets, so wxWidgets must be installed first. We will install wxWidgets with the GCC that is packaged with GHC, to prevent incompatibilities between object/archive files.
You need mingw32-make.exe from MinGW and sh.exe from MSYS in your search path (look for sh.exe in your GHC directory tree). If you do not have it yet, install GIT. Download wx-config.exe (a new version for wxWidgets > 3.0) and copy it somewhere into your search path. It is also possible to download the source for wx-config from the official wxHaskell repository; compile it with

 c++ wx-config.cpp -o wx-config

The C++ compiler comes with GHC.

Installing wxWidgets

Install the wxWidgets source in C:\Libs\wxWidgets\3.1.1
Commands to compile wxWidgets and wxHaskell with Haskell Platform 2014.2.0.0 and later:

Set WXWIDGETS_VERSION=3.1.1
Set WXWIN=C:\Libs\wxWidgets\%WXWIDGETS_VERSION%
Cd %WXWIN%\build\msw

Edit config.gcc so that the following values are set:

SHARED ?= 1
BUILD ?= release

If you are using GCC 5.2.0 or later (included with GHC 7.10.3 and later), change CXXFLAGS as well:

CXXFLAGS ?= -std=gnu++11 -Wno-deprecated-declarations

(Without -Wno-deprecated-declarations, you will get a huge amount of useless 'deprecated' messages.) If you want to compile 64 bit binaries, set the following as well (64 bit compilation requires GCC > 4.6, which comes with GHC > 7.10):

# Standard flags for CC 
CFLAGS ?= -m64

# Standard flags for C++ 
CXXFLAGS ?= -m64 -std=gnu++11 -Wno-deprecated-declarations

# Standard preprocessor flags (common for CC and CXX) 
CPPFLAGS ?= -D_M_AMD64

Edit ..\..\include\wx\msw\setup.h, change line 788 (may differ in later versions of wxWidgets, look for the #define for none-_MSC_VER compilers) from

#   define wxUSE_GRAPHICS_CONTEXT 0

to

#   define wxUSE_GRAPHICS_CONTEXT 1


Set the environment variables

  • for Haskell Platform 2014.2.0.0:
Set HASKELL_COMPILER_DIR=C:\Program Files\Haskell Platform\2014.2.0.0
Set PATH=%HASKELL_COMPILER_DIR%\mingw\libexec\gcc\mingw32\4.5.2\;%HASKELL_COMPILER_DIR%\lib\extralibs\bin;%HASKELL_COMPILER_DIR%\bin;%HASKELL_COMPILER_DIR%\mingw\bin;%path%
Set LIBRARY_PATH=%HASKELL_COMPILER_DIR%\mingw\lib;%HASKELL_COMPILER_DIR%\mingw\lib\gcc\mingw32\4.5.2;%LIBRARY_PATH%
  • for Haskell Platform 7.10.2-a:
Set HASKELL_COMPILER_DIR=C:\Program Files\Haskell Platform\7.10.2-a
Set Path=%HASKELL_COMPILER_DIR%\lib\extralibs\bin;%HASKELL_COMPILER_DIR%\bin;%HASKELL_COMPILER_DIR%\mingw\bin;%path%
Set LIBRARY_PATH=%WXWIN%\lib\gcc_lib;%HASKELL_COMPILER_DIR%\mingw\lib;%LIBRARY_PATH%

Clean and build wxWidgets, using the MinGW shell:

sh -c "mingw32-make -f makefile.gcc clean"
sh -c "mingw32-make -f makefile.gcc all"

There will be many linker warnings for old versions of GCC, those are solved in a more recent GCC version. The result is now in %WXWIN%\lib\gcc_dll

If you get a message like

'c:/Program' is not recognized as an internal or external command,

there is probably a space in the path to an executable. It is better to install the Haskel Platform in a directory without spaces in the full name, but there is another solution: use the old fashioned short names, like:

Set HASKELL_COMPILER_DIR=C:\PROGRA~1\HASKEL~1\7.10.2-a

(Use the MS-DOS command For %i In (ghc.exe) Do Echo %~sdp$PATH:i to see the path to GHC with short names)

If you get a message about denied access: if you already compiled and ran a wxHaskell program, the wxWidgets DLLs are loaded and cannot be overwritten. Restart the computer.

Installing wxHaskell

Using the environment variables HASKELL_COMPILER_DIR and WXWIN from the previous subsection:

Set WXCFG=gcc_dll\mswu
Set CPLUS_INCLUDE_PATH=%HASKELL_COMPILER_DIR%\mingw\lib\gcc\mingw32\4.5.2\include\c++;%WXWIN%\include
Set LIBRARY_PATH=%WXWIN%\lib\gcc_lib;%HASKELL_COMPILER_DIR%\mingw\lib\


From GitHub

You can get wxHaskell from Hackage and from GitHub; to install the most recent version of wxHaskell from the repository:

Cd <Where\you\want\to\install\wxHaskell>
git clone https://github.com/wxHaskell/wxHaskell.git
Cd wxHaskell
cabal install .\wxdirect
cabal install .\wxc
cabal install .\wxcore
cabal install .\wx

Make sure that all below mentioned DLLs are in the search path and try a sample program:

Cd samples\wxcore
ghc BouncingBalls
BouncingBalls

Click with the left mouse button on the window to create new bouncing balls.

If you get an exception code 0xc000007b immediately after starting your wxHaskell program, there is a mismatch between bitness of your program and the bitness of the wxWidgets DLLs. Note, that the package wxc checks the bitness at installation time, but things can go wrong afterwards, like changing the search path to point to a different version of the wxWidgets DLLs.

From Hackage

To install the wxHaskell from Hackage:

cabal install wx

wxWidgets 3.0 and wxHaskell 0.91.x

Windows Haskell Platform wxWidgets
8.1 2013.2.0.0 3.0.1
8.1 2014.2.0.0 3.0.1, 3.0.2


Prerequisites:

  • If you want to install from Hackage: MinGW 5.1.6 and MSYS 1.0.11 (a recent version of MinGW will result in incompatible DLLs). You must select the C++ compiler and MinGW-make options when installing MinGW. Add the full path to directories MinGW\bin and msys\1.0\bin to your search path. If you install the most recent version from GitHub, use the same version of GCC as the one that comes with GHC (use command gcc --version), to prevent compatibility problems.


Environment variables:

  • GHC_VERSION: 7.8.3 (some recent version)
  • WXC_VERSION: 0.91.0.0 (preferably the most recent version, see Hackage)
  • WXWIN: C:\wxWidgets-3.0.3
  • WXCFG: gcc_dll\mswu
  • PATH: (add these) %WXWIN%\lib\gcc_dll;%WXWIN%;%APPDATA%\cabal\bin;%APPDATA%\cabal\i386-windows-ghc-%GHC_VERSION%\wxc-%WXC_VERSION%

If you are using a cabal sandbox, you must add the following to your search path:

  • .cabal-sandbox\bin

to ensure that wxdirect.exe can be found.

Steps:

  1. Make sure, that the GCC from the MinGW package is used for compilation of wxWidgets, by adding its directory to the start of the search path, with a command like:
    Set path=C:\MinGW\bin;%path%
    
  2. Download wxWidgets 3.0.3 source
  3. Extract to C:\wxWidgets-3.0.3
  4. Build wxWidgets-3.0.3
    Edit wxwidgets-src-dir\build\msw\config.gcc so that the following values are set:
     SHARED ?= 1
     BUILD ?= release
    

    Then (in cmd.exe, not bash):

     cd wxwidgets-src-dir\build\msw
     sh
     mingw32-make -f makefile.gcc
    
  5. Download wx-config.exe (a new version for wxWidgets > 3.0) and copy it somewhere into your search path, for instance via
    copy wx-config.exe %CABAL_DIR%\bin
    
  6. Make sure, that the GCC that comes with GHC is used for the rest of the procedure, by adding its directory to the search path, with a command like:
    Set path=C:\Haskell\Haskell Platform\2014.2.0.0\mingw\bin\;%path%
    
  7. Install the wxHaskell libraries
  8. To get the most recent version (using Git):
    git clone git://github.com/wxHaskell/wxHaskell.git
    cd wxHaskell\wxdirect
    cabal update
    cabal install
    cd ..\wxc
    cabal install
    cd ..\wxcore
    cabal install
    cd ..\wx
    cabal install
    

    Or, for the Hackage version:

    cabal update
    cabal install wx
    

    Or, if you want to install the dependencies separately:

    cabal update
    cabal install wxdirect
    cabal install wxc
    cabal install wxcore
    cabal install wx
    
  9. Install the DLLs described in the next subsection


DLLs

In order to run a wxHaskell application, Windows must be able to find the following wxWidgets DLLs (see Search Path Used by Windows to Locate a DLL):

  • wxWidgets-x.y.z\lib\gcc_dll\*.dll

The following file can be found in directory wxc\dist\build\, after building package wxc in directory wxc:

  • wxc.dll (be sure to recompile and copy this one when you compile your application with a new compiler)

If you are using GHC 7.10.3 or later, the rest of the necessary DLLs can be found in the mingw\bin directory of your GHC installation. For an earlier GHC, you can find the DLLs in the wxInstall Abriline packages, or as described below.

The following DLLs can be found in directory "Haskell Platform\2014.2.0.0\mingw\bin\", or in ghc-7.10.1\mingw\bin\ if you installed the compiler only (change revision as needed):

  • libgcc_s_dw2-1.dll
  • libstdc++-6.dll
  • mingwm10.dll

Some wxHaskell applications also require the following DLLs:

  • uuid.dll
  • perl510.dll
  • libapr-1.dll
  • libapriconv-1.dll
  • libaprutil-1.dll

These DLLs can be obtained by installing XAMPP 1.7.4; the DLLs are in the directories:

  • xampp\perl\site\lib\auto\APR\UUID
  • xampp\perl\bin
  • xampp\apache\bin

If there are still DLLs missing, you can find out which, using cygcheck from the Cygwin project. Note, that you will get problems if you have both MinGW and Cygwin in your search path; it is best to specify the full path to cygcheck.exe, or copy cygcheck.exe to some location in the search path. Sample command:

 C:\programs\cygwin\bin\cygcheck.exe .\h.exe

(the .\ must be specified)

wxWidgets 2.8 and wxHaskell 0.13.x

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


DLLs

In order to run a wxHaskell application, the following DLLs must be in the search path:

  • mingwm10.dll; this can be found in directory "Haskell Platform\2012.2.0.0\mingw\bin\", or in ghc-7.4.2\mingw\bin\ if you installed just the compiler (change revision as needed)
  • wxmsw28u_gcc_custom.dll


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


See also