Personal tools

Windows

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(Adding installation instructions for windows 7)
(clarifying windows installations instructions)
Line 7: Line 7:
 
* Download cabal binaries from http://www.haskell.org/cabal/download.html
 
* Download cabal binaries from http://www.haskell.org/cabal/download.html
   
Add the following to path :
+
Add the following to the path :
   
 
* <hask>ghc/bin</hask> (should contain <hask>ghc.exe</hask> etc)
 
* <hask>ghc/bin</hask> (should contain <hask>ghc.exe</hask> etc)
Line 13: Line 13:
 
* <hask>cabal/</hask> (should contain the cabal binary)
 
* <hask>cabal/</hask> (should contain the cabal binary)
   
And make sure that the following environment variable is
+
If you launch <hask>msys2_shell.bat</hask> (as opposed to <hask>mingw32_shell.bat</hask> or <hask>mingw64_shell.bat</hask>) then make sure that the following environment variable is defined :
defined :
 
   
 
* <hask>MSYSTEM=MINGW32</hask> or <hask>MSYSTEM=MINGW64</hask>
 
* <hask>MSYSTEM=MINGW32</hask> or <hask>MSYSTEM=MINGW64</hask>
  +
  +
Then test by firing up either <hask>msys2_shell.bat</hask>, <hask>mingw32_shell.bat</hask>, or <hask>mingw64_shell.bat</hask> and then executing the following sequence of commands :
   
Then test by firing up the msys shell and doing :
+
* <hask>
  +
mkdir test
  +
cd test
  +
cabal sandbox init
  +
cabal install hoogle
  +
</hask>
   
* <hask>cabal install hoogle</hask>
+
Note that the absence of the environment variables above will result in linker errors when building hoogle.
   
 
== Editors ==
 
== Editors ==

Revision as of 15:58, 26 June 2014

Contents

1 Quickstart on Windows 7

For a minimal setup :

Add the following to the path :

  • ghc/bin
    (should contain
    ghc.exe
    etc)
  • ghc/mingw/bin
    (should contain
    gcc.exe
    etc)
  • cabal/
    (should contain the cabal binary)
If you launch
msys2_shell.bat
(as opposed to
mingw32_shell.bat
or
mingw64_shell.bat
) then make sure that the following environment variable is defined :
  • MSYSTEM=MINGW32
    or
    MSYSTEM=MINGW64
Then test by firing up either
msys2_shell.bat
,
mingw32_shell.bat
, or
mingw64_shell.bat
and then executing the following sequence of commands :
  • mkdir test
    cd test
    cabal sandbox init
    cabal install hoogle

Note that the absence of the environment variables above will result in linker errors when building hoogle.

2 Editors

3 Compilers/interpreters

4 Tools for compilation

  • As some of the packages contain Unix/Linux specific scripts/commands, you need MinGW and MSYS to simulate a Unix environment. In some cases you need Cygwin instead. If you use msysgit on Windows already, all you need to do is add MinGW to your path.
  • If you need to link to C-software, define environment variable C_INCLUDE_PATH that lists the directories where the header files can be found, for example:
    Set C_INCLUDE_PATH=C:\usr\local\include;C:\usr\local\include\SDL
(It is advisable to use paths without spaces, because some scripts in the MinGW/MSYS environment have problems with spaces in paths.)
For linking the libraries, you need to define environment variable LIBRARY_PATH as well, listing the directories where .a and .lib files can be found. In case C++ software must be compiled, define CPLUS_INCLUDE_PATH to list the directories with C++ header files.
If you have GHC >= 7.0.1, see Using shared libraries or Building and using Win32 DLLs

5 Libraries

  • GUI : Gtk2Hs - A binding of GTK+ in Haskell. Note: this requires installing GTK+ on windows.
  • Win32 - low levelish bindings to Windows API. Comes with GHC and non-minimal Hugs distribution. Win32 git repo
  • winerror: Error handling for foreign calls to the Windows API

6 Special tips and tricks for Windows

  • If there are DLLs missing from your environment, 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.
Another option is Dependency Walker; this tool can also be used to find out, in which DLL a crash occurs.
  • Instead of using WinGHCi, one can also run GHCi in shell mode in Emacs — do 'M-x shell' in Emacs, then type 'ghci'.
  • GHCi on Cygwin: When running GHC under a Cygwin shell on Windows, Ctrl-C sometimes doesn't work. A workaround is to use the rlwrap program to invoke GHCi : In addition to proper Ctrl-C, you also get Emacs (or vi) key bindings and command history across sessions, which saves you a load of typing.
  • If a package depends (either directly or indirectly) on the unix package, you cannot compile it on Windows.
A simple way to see, if a package X depends on unix, is giving the command:
   cabal install X --dry-run
This will list all packages that would be installed
  • If you are missing or need to distribute libraries with an application, the correct place to put them is *NOT* in \WINDOWS\System32 as once was the practice in the early days of Windows. All sane applications/installers keep their own private dependencies in the application directory. E.g., if the user has chosen to install your application to C:\Program Files\Foo then it is best to install any DLLs in the same location.
  • When compiling a program with GUI, use the compiler option -optl-mwindows to prevent a DOS-shell being displayed behind your GUI. (This passes the option -mwindows to the linker.)
  • Source files from Unix(-like) systems have lines terminated with Line Feed only; if your favorite editor cannot handle this, you can convert the files to MS-DOS format with the unix2dos command (from the mingw-utils package). For more information, give command: unix2dos --help
Note, that GHC can handle source files in Unix format.
  • To convert a set of files to MS-DOS format (note: this might damage binary files):
C:\MSYS\1.0\bin\find . -type f -exec unix2dos {} ;
Note: the find command included in MSYS is different from the MS-DOS find command, therefore, you need to specify the entire path to this command.

7 Binary downloads

7.1 Haskell

Below a list of binary packages for Windows. To be sure you get the most recent version of each, it is best to download the source from Hackage and compile (except for the Haskell Platform).

7.2 Development

CVS 1.11.22 (website)  ; Python 2.4.3 (website)  ; Scons (website)  ; SVN 1.3.2 (website)  ; TextPad (website)

8 Shipping Installable Applications

  • bamse lets you build windows installers for your Haskell app (MSI).
  • Inno Setup is another tool to create windows installers.
  • WiX Toolset, builds Windows installation packages from XML source code
  • Zero Install creates packages for several platforms ("a decentralised cross-distribution software installation system")