1 How to use Cabal in Windows
\r
2 ===========================
\r
4 This document describes how to use Cabal in a Windows system. See the
\r
5 :ref:`Further reading` section for some other references that might provide some
\r
6 more explanations. For a TL;DR, jump to the :ref:`Complete configuration`.
\r
8 Install the Haskell environment
\r
9 -------------------------------
\r
11 Haskell development on Windows makes use of the `MSYS2 <https://www.msys2.org/>`_
\r
14 The recommended way of setting up a Haskell environment in Windows is by using
\r
15 `GHCup <https://www.haskell.org/ghcup/>`_. Follow the steps outlined in its
\r
16 webpage to install at least GHC and Cabal. GHCup will install its own MSYS2
\r
17 system in your computer unless told not to do so: refer to `its documentation
\r
18 <https://www.haskell.org/ghcup/install/#windows_1>`_ for more information.
\r
21 Stack is another tool you can use to set up a Haskell environment on Windows. Stack
\r
22 can be installed on its own or via GHCup. See
\r
23 `Stack's webpage <https://docs.haskellstack.org/en/stable/>`_ and/or
\r
24 `GHCup's section on Stack integration <https://www.haskell.org/ghcup/guide/#stack-integration>`_,
\r
25 in particular the `Windows related subsection <https://www.haskell.org/ghcup/guide/#windows>`_.
\r
27 Ensure that Cabal can call the tools it needs
\r
28 ---------------------------------------------
\r
30 Cabal sometimes needs to call tools that do not come with Windows (such as
\r
31 ``make`` or even ``git``). The MSYS2 project makes many of them available on
\r
32 Windows. The directories where those are located need to be made visible in the
\r
33 ``PATH`` when executing ``cabal``. For that, Cabal provides the
\r
34 ``extra-prog-path`` configuration option. Your :ref:`global configuration
\r
35 <config-file-discovery>` should include this option:
\r
39 extra-prog-path: <msys-dir>\<environment>\bin
\r
42 Where ``<msys-dir>`` points to the location of your MSYS2 installation. Refer to
\r
43 GHCup's documentation on the default location of this directory.
\r
44 ``<environment>`` has to be one of the environments of MSYS2, which for GHCup is
\r
45 ``mingw64``. You can learn more about the different environments in the `MSYS2
\r
46 documentation <https://www.msys2.org/docs/environments/>`_.
\r
50 Unless told otherwise, the GHCup bootstrap script already adds these directories to `extra-prog-path`
\r
53 Ensure that Cabal can use system libraries
\r
54 ------------------------------------------
\r
56 Third-party libraries can be installed using the ``pacman`` package manager on
\r
57 the MSYS2 installation. When installing a third party package its libraries and
\r
58 header files will (usually) be placed in
\r
59 ``<msys-dir>\<environment>\{lib,include}`` respectively. These directories need
\r
60 to be specified in the ``extra-lib-dirs`` and ``extra-include-dirs``
\r
61 respectively. Your :ref:`global configuration <config-file-discovery>` should
\r
62 include these options:
\r
66 extra-include-dirs: <msys-dir>\<environment>\include
\r
67 extra-lib-dirs: <msys-dir>\<environment>\lib
\r
72 Unless told otherwise, the GHCup bootstrap script already adds these directories to `extra-include-dirs` and `extra-lib-dirs`
\r
77 Packages in the ``msys/`` repo are not native Windows libraries and will
\r
78 probably not work when one tries to link to them. Install the packages for
\r
79 your selected environment, which for GHCup is ``mingw64/``. Refer to `MSYS2's
\r
80 package management documentation
\r
81 <https://www.msys2.org/docs/package-management/>`_ for more information.
\r
83 Ensure that Cabal can call Haskell tools
\r
84 ----------------------------------------
\r
86 Haskell tools are located in two places:
\r
88 - ``<ghcup-dir>\bin`` for standard Haskell tools such as GHC, Cabal, Haddock, ``hsc2hs``...
\r
90 - The ``installdir`` that Cabal is configured with for user-installed Haskell tools.
\r
92 For Cabal to be able to invoke these tools, those directories need to be made
\r
93 visible in the ``PATH``. Your :ref:`global configuration <config-file-discovery>` should
\r
94 include these options:
\r
98 installdir: <installdir>
\r
99 extra-prog-path: ...
\r
105 Unless told otherwise, the GHCup bootstrap script already adds these directories to `extra-prog-path`
\r
108 .. _Complete configuration:
\r
110 Complete configuration
\r
111 ----------------------
\r
113 The complete :ref:`global configuration <config-file-discovery>` should finally
\r
118 installdir: <installdir>
\r
119 extra-include-dirs: <msys-dir>\<environment>\include
\r
120 extra-lib-dirs: <msys-dir>\<environment>\lib
\r
121 extra-prog-path: <ghcup-dir>\bin
\r
123 <msys-dir>\<environment>\bin
\r
128 Unless told otherwise, the GHCup bootstrap script already sets this configuration file to the right
\r
131 .. _Further reading:
\r
136 - MSYS2 homepage: https://www.msys2.org
\r
137 - MinGW-W64 homepage: https://www.mingw-w64.org/
\r
138 - Setting up Windows to build GHC:
\r
139 https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation/windows
\r
140 - Some definitions and useful tools:
\r
141 https://gitlab.haskell.org/ghc/ghc/-/wikis/surviving-windows
\r
146 These links are outdated but still useful to understand the overall picture:
\r
148 - GHC's wiki about the Windows platform (outdated, GHC now uses MSYS2):
\r
149 https://gitlab.haskell.org/ghc/ghc/-/wikis/building/platforms/windows
\r
150 - The Windows toolchain (outdated, GHC now uses the ``CLANG64`` environment):
\r
151 https://gitlab.haskell.org/ghc/ghc/-/wikis/working-conventions/windows-toolchain
\r
152 - Haskell Wiki on Windows (outdated, it talks about MSYS and old tools such as
\r
153 the Haskell platform): https://wiki.haskell.org/Windows
\r