[Haskell-cafe] text-icu (and FFI in general) on Windows 64 bits

Yitzchak Gale gale at sefer.org
Tue May 19 16:51:46 UTC 2015

I was finally successful in getting text-icu to
work on Windows 64 bits. This is probably
an indication of what to expect in general
for packages requiring FFI on Windows
64 bits.

In the past, on 32 bits, the standard Windows
binary distribution from the ICU site could be
used together with msys/mingw, even though
it was officially only for MSVC. This no longer
seems to be the case for 64 bits. When I
build text-icu in that way with a 64 bit GHC and
the Windows 64-bit binary ICU distribution for
MSVC, the resulting EXEs segfault as soon as
any function from text-icu is called.

There is no official ICU download for
mingw-w64 binaries. But happily, the MSYS2
project does provide a pre-built ICU binary
distribution for mingw-w64. It tends to be quite
up-to-date; the current version is ICU 55.1.

Note, however, that I was *not* able to use the
partial MSYS2 that comes with MinGHC, because
pacman seems to be missing.

So the solution is:

1. Download and install 64-bit MSYS2, following the
instructions on the site:


2. In the MSYS2 shell window, get the ICU package
for mingw-w64:

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

3. Now you can build the Haskell text-icu library
using this command:

cabal install --extra-lib-dirs="c:\path\to\msys64\mingw64\lib"
--extra-include-dirs="c:\path\to\msys64\mingw64\include" text-icu

4. Provide the following DLLs with your EXE that uses


Get them from: c:\path\to\msys64\mingw64\bin

This not only compiles, but EXEs produced using
this library actually run without segfaulting.

You can even compile native Windows EXEs from
C using ICU this way, with the gcc that is put on your
path by the Haskell Platform installer (and probably
also MinGHC, but I didn't try that). Just include
-L and -I options to gcc with the same paths as
above, and make sure to specify -licuuc -licudt
etc. as needed.


More information about the Haskell-Cafe mailing list