Search code examples
cairocabal-install

Installing Cairo, Helm on Windows


How do I install Helm (https://hackage.haskell.org/package/helm) on Windows 7 (64-bit)?

(Update: I had posted a lot of error messages here, but I've moved them to my answer to not clutter up the question.)


Solution

  • Installation for Windows 64-bit:

    I'm including error messages, for if you follow all the steps up to that point and then just try to install directly. This is a conglomeration of a bunch of ad-hoc steps from following many different posts. Any simplification would be appreciated!

    Note: Do all work in directories without spaces. I'm doing all work in C:/PF; modify this to your directory.

    1. Download MSYS2-x86_64 from https://msys2.github.io/ and install it. Cabal install cairo (or helm) will give something like:

      Configuring cairo-0.13.1.0... setup.exe: Missing dependencies on foreign libraries:

      • Missing C libraries: z, cairo, z, gobject-2.0, ffi, pixman-1, fontconfig, expat, freetype, iconv, expat, freetype, z, bz2, harfbuzz, glib-2.0, intl, ws2_32, ole32, winmm, shlwapi, intl, png16, z
    2. Download C libraries. In MINGW64 (NOT MSYS2 - I had trouble with MSYS2 at random stages in the process), use the package manager:

      pacman -Ss cairo

    to search for the Cairo package. You'll find "mingw64/mingw-w64-x86_64-cairo", so install that:

    pacman -S mingw64/mingw-w64-x86_64-cairo
    

    *.pc files should have been added to C:\PF\msys64\mingw64\lib\pkgconfig and C:\PF\msys64\usr\lib\pkgconfig. (pkg-config needs to be able to find these files. It looks in PKG_CONFIG_PATH, which by default should have the lib/pkgconfig folder above. Moving the file here is easiest. See Can't install sdl2 via cabal) If you get

    The pkg-config package ... version ... cannot be found 
    

    errors then check your *.pc files.

    Repeat with other required libraries, like atk

    pacman -S mingw64/mingw-w64-x86_64-atk
    

    (I don't know the complete list, but error messages later on will let you know what to get.)

    1. Get the development files for these libraries (as suggested by How to install cairo on Windows). Most of them are bundled up at http://ftp.gnome.org/pub/gnome/binaries/win64/gtk+/2.22/. Unzip.

      • Copy files (.a, .dll.a) in lib to C:\PF\msys64\mingw64\lib. Copy the pkgconfig folder, which contains the .pc files.
      • Copy files in include to C:\PF\msys64\mingw64\include.
      • Add C:\PF\gtk+-2.22.1\bin to the path.

    (2) and (3) might be redundant. I don't know - I did them both.

    At this point you can probably do "cabal install cairo". (Warning: if your end goal is something else, you may not want to "cabal install" intermediate packages, see https://wiki.haskell.org/Cabal/Survival#Issue_.232_--_Not_installing_all_the_packages_in_one_go.) See (4) for the syntax in specifying extra-include-dirs and extra-lib-dirs (but if you copied the files above this shouldn't be necessary),

    Any time you get

    Missing (or bad) header file
    

    check to see you copied the *.h files to mingw64\include and/or add the include folder to the PATH. Use cabal install -v3 to get verbose error messages if the problem persists.

    If you get something like

    cairo-0.13.1.0: include-dirs: /mingw64/include/freetype2 is a relative path
    which makes no sense (as there is nothing for it to be relative to). You can
    make paths relative to the package database itself by using ${pkgroot}. (use
    --force to override)
    

    try --ghc-pkg-options="--force" (as mentioned at https://github.com/gtk2hs/gtk2hs/issues/139).

    1. Get SDL. Otherwise you'll get

      configure: error: *** SDL not found! Get SDL from www.libsdl.org. If you already installed it, check it's in the path. If problem remains, please send a mail to the address that appears in ./configure --version indicating your platform, the version of configure script and the problem. Failed to install SDL-0.6.5.1

    Follow the instructions in (2) to get sdl/sdl2 libraries. (See instructions here Installing SDL on Windows for Haskell (GHC).)

    The new version helm-0.7.1 requires sdl2, but there are other dependency issues with helm-0.7.1 as of writing. Download SDL from http://sourceforge.net/projects/msys2/files/REPOS/MINGW/x86_64/ (direct download link to newest version as of writing http://sourceforge.net/projects/msys2/files/REPOS/MINGW/x86_64/mingw-w64-x86_64-SDL-1.2.15-7-any.pkg.tar.xz.sig/download), unzip. "cabal install sdl" gives

    * Missing (or bad) header file: SDL/SDL.h
    * Missing C library: SDL
    This problem can usually be solved by installing the system package that
    provides this library (you may need the "-dev" version). If the library is
    already installed but in a non-standard location then you can use the flags
    --extra-include-dirs= and --extra-lib-dirs= to specify where it is.
    

    so we specify where the dirs are (change the name depending on where you extracted sdl to)

    cabal install sdl --extra-include-dirs=C:/PF/sdl\include --extra-lib-dirs=C:/sdl/lib
    

    If you got SDL2 (http://libsdl.org/download-2.0.php) (for a newer version of Helm): there is a fatal bug that hasn't been fixed in the release version. (If you don't fix it, cabal install -v3 things which depends on it will give error

    winapifamily.h: No such file or directory 
    

    ("winapifamily.h: No such file or directory" when compiling SDL in Code::Blocks) Download https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h, replace the file in the include folder and in C:/PF/msys64/mingw64/include/SDL2.

    1. Download gtk2hs from http://code.haskell.org/gtk2hs and run

    the following

    cd gtk2hs/tools
    cabal install
    cd ../glib
    cabal install
    cd ../gio
    cabal install
    cd ../pango
    cabal install --ghc-pkg-options="--force"
    

    (Maybe you have already installed glib and gio from before? I did this step because normal install of Pango caused an error for me (https://github.com/gtk2hs/gtk2hs/issues/110)

    pango-0.13.1.0: include-dirs: /mingw64/include/freetype2 is a relative path
    which makes no sense (as there is nothing for it to be relative to). You can
    make paths relative to the package database itself by using ${pkgroot}. (use
    --force to override)
    
    1. Once the Helm developers get things updated you should be able to do "cabal install helm" but right now there seem to be dependency issues. For me, cabal automatically tries to install helm-0.4 (probably because 0.4 didn't give upper bounds on dependencies, while newer versions do. You could try "cabal unpack"ing and deleting the upper bounds...). Then

      cabal unpack helm-0.4

    Installing gives an error because "pure" got moved to Prelude. Open helm-0.4\src\FRP\Helm\Automaton.hs and change line 17:

    import Prelude hiding (id, (.), pure)
    

    Now

    cabal install
    
    1. Try to compile and run a program using Helm

    (This is 0.4 - look on the website for a newer sample if you tried a newer Helm)

    import FRP.Helm
    import qualified FRP.Helm.Window as Window
    
    render :: (Int, Int) -> Element
    render (w, h) = collage w h [filled red $ rect (fromIntegral w) (fromIntegral h)]
    
    main :: IO ()
    main = run $ fmap (fmap render) Window.dimensions
    

    If you get an error about a missing .dll (sdl.dll), find it in a bin/ folder and add the folder to your PATH (or copy it to somewhere on your path).