Difference between revisions of "WxHaskell/Windows"

From HaskellWiki
Jump to navigation Jump to search
(→‎wxWidgets 3.0 and wxHaskell >= 0.92: Added installation from Hackage; divided text in subsections)
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
  +
== wxWidgets 3.0 and wxHaskell >= 0.92 ==
  +
  +
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.
  +
<br>
  +
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. 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.
  +
  +
=== Installing wxWidgets ===
  +
  +
Install the [http://wxwidgets.org/ wxWidgets source] in C:\Libs\wxWidgets\3.0.2
  +
<br>
  +
Commands to compile wxWidgets and wxHaskell with Haskell Platform 2014.2.0.0 (newer versions of GHC can be used as well, but need different directories in the search path):
  +
<pre>
  +
Set WXWIDGETS_VERSION=3.0.2
  +
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 want to compile 64 bit binaries, set the following as well:
  +
<pre>
  +
# Standard flags for CC
  +
CFLAGS ?= -m64
  +
  +
# Standard flags for C++
  +
CXXFLAGS ?= -m64
  +
  +
# Standard preprocessor flags (common for CC and CXX)
  +
CPPFLAGS ?= -D_M_AMD64
  +
</pre>
  +
  +
Edit ..\..\include\wx\msw\setup.h, change line 788 from
  +
<pre>
  +
# define wxUSE_GRAPHICS_CONTEXT 0
  +
</pre>
  +
to
  +
<pre>
  +
# define wxUSE_GRAPHICS_CONTEXT 1
  +
</pre>
  +
<br>
  +
Next, enter the commands (some editing needed):
  +
<pre>
  +
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%
  +
sh -c "mingw32-make -j -f makefile.gcc clean"
  +
sh -c "mingw32-make -j -f makefile.gcc all"
  +
Rem There will be many linker warnings, those are solved in a more recent GCC version.
  +
Rem The result is now in C:\Libs\wxWidgets\%WXWIDGETS_VERSION%\lib\gcc_dll
  +
</pre>
  +
  +
  +
=== 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.
  +
  +
  +
==== From Hackage ====
  +
  +
To install the wxHaskell from Hackage:
  +
<pre>
  +
cabal install wx
  +
</pre>
  +
 
== wxWidgets 3.0 and wxHaskell 0.91.x ==
 
== wxWidgets 3.0 and wxHaskell 0.91.x ==
   
Line 8: Line 104:
 
|| 8.1 || 2013.2.0.0 || 3.0.1
 
|| 8.1 || 2013.2.0.0 || 3.0.1
 
|-
 
|-
|| 8.1 || 2014.2.0.0 || 3.0.1
+
|| 8.1 || 2014.2.0.0 || 3.0.1, 3.0.2
 
|-
 
|-
 
|}
 
|}
Line 14: Line 110:
   
 
Prerequisites:
 
Prerequisites:
* [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 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:
 
Environment variables:
   
* GHC_VERSION: 7.6.3 (some recent version)
+
* GHC_VERSION: 7.8.3 (some recent version)
* WXC_VERSION: 0.90.1.1 (see [http://hackage.haskell.org/package/wxc Hackage])
+
* WXC_VERSION: 0.91.0.0 (preferably the most recent version, see [http://hackage.haskell.org/package/wxc Hackage])
* WXWIN: C:\wxWidgets-3.0.1
+
* WXWIN: C:\wxWidgets-3.0.2
 
* WXCFG: gcc_dll\mswu
 
* WXCFG: gcc_dll\mswu
* PATH: (add these) %WXWIN%\lib\gcc_dll;%WXWIN%;%APPDATA%\cabal\wxc-%WXC_VERSION%\%GHC_VERSION%
+
* 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 cabal-dev, you must add the following to your search path:
+
If you are using a cabal sandbox, you must add the following to your search path:
  +
* .cabal-sandbox\bin
* wxdirect\dist\build\wxdirect
 
  +
to ensure that wxdirect.exe can be found.
* wxc\dist\build
 
to ensure that wxdirect.exe and wxc.dll can be found.
 
   
 
Steps:
 
Steps:
Line 37: Line 132:
 
Set path=C:\MinGW\bin;%path%
 
Set path=C:\MinGW\bin;%path%
 
</pre>
 
</pre>
<li> Download [http://wxwidgets.org/downloads wxWidgets 3.0.1 source]
+
<li> Download [http://wxwidgets.org/downloads wxWidgets 3.0.2 source]
<li> Extract to C:\wxWidgets-3.0.1
+
<li> Extract to C:\wxWidgets-3.0.2
<li> [http://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW Build wxWidgets-3.0.1]
+
<li> [http://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW Build wxWidgets-3.0.2]
 
<br>Edit <tt>wxwidgets-src-dir\build\msw\config.gcc</tt> so that the following values are set:
 
<br>Edit <tt>wxwidgets-src-dir\build\msw\config.gcc</tt> so that the following values are set:
 
<pre>
 
<pre>
Line 57: Line 152:
 
<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:
 
<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>
 
<pre>
Set path=C:\Haskell\Haskell Platform\2013.2.0.0\mingw\bin\;%path%
+
Set path=C:\Haskell\Haskell Platform\2014.2.0.0\mingw\bin\;%path%
 
</pre>
 
</pre>
 
<li> Install the wxHaskell libraries</li>
 
<li> Install the wxHaskell libraries</li>
Line 86: Line 181:
 
cabal install wx
 
cabal install wx
 
</pre>
 
</pre>
  +
<li> Install the DLLs described in the next subsection
 
</ol>
 
</ol>
   
Line 98: Line 194:
 
* wxc.dll (be sure to recompile and copy this one when you compile your application with a new compiler)
 
* wxc.dll (be sure to recompile and copy this one when you compile your application with a new compiler)
   
Furthermore, the following DLLs need to be in the search path (these can be found in directory "Haskell Platform\2012.2.0.0\mingw\bin\", or in ghc-7.4.2\mingw\bin\ if you installed the compiler only (change revision as needed)):
+
Furthermore, the following DLLs need to be in the search path (these 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
 
* libgcc_s_dw2-1.dll
 
* libstdc++-6.dll
 
* libstdc++-6.dll
Line 119: Line 215:
 
C:\programs\cygwin\bin\cygcheck.exe .\h.exe
 
C:\programs\cygwin\bin\cygcheck.exe .\h.exe
 
(the .\ must be specified)
 
(the .\ must be specified)
  +
   
 
== wxWidgets 2.8 and wxHaskell 0.13.x ==
 
== wxWidgets 2.8 and wxHaskell 0.13.x ==
Line 170: Line 267:
   
 
Finally call <code>cabal install wx</code>.
 
Finally call <code>cabal install wx</code>.
  +
   
 
== See also ==
 
== See also ==

Revision as of 18:32, 3 September 2015

wxWidgets 3.0 and wxHaskell >= 0.92

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

Installing wxWidgets

Install the wxWidgets source in C:\Libs\wxWidgets\3.0.2
Commands to compile wxWidgets and wxHaskell with Haskell Platform 2014.2.0.0 (newer versions of GHC can be used as well, but need different directories in the search path):

Set WXWIDGETS_VERSION=3.0.2
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 want to compile 64 bit binaries, set the following as well:

# Standard flags for CC 
CFLAGS ?= -m64

# Standard flags for C++ 
CXXFLAGS ?= -m64

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

Edit ..\..\include\wx\msw\setup.h, change line 788 from

#   define wxUSE_GRAPHICS_CONTEXT 0

to

#   define wxUSE_GRAPHICS_CONTEXT 1


Next, enter the commands (some editing needed):

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%
sh -c "mingw32-make -j -f makefile.gcc clean"
sh -c "mingw32-make -j -f makefile.gcc all"
Rem There will be many linker warnings, those are solved in a more recent GCC version.
Rem The result is now in C:\Libs\wxWidgets\%WXWIDGETS_VERSION%\lib\gcc_dll


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.


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.2
  • 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.2 source
  3. Extract to C:\wxWidgets-3.0.2
  4. Build wxWidgets-3.0.2
    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)

Furthermore, the following DLLs need to be in the search path (these 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