View on GitHub


Documenting everything about OCaml


Windows Support

Many projects, including the OCaml compiler itself, rely on the Unix shell and its various utilities. Windows doesn’t include these utilities or any of their substitutes (or even a built-in compiler), making it much harder to support a complex library on Windows.

Nevertheless, OCaml is gradually making a transition towards increased Windows support.


  • OCaml on WSL (Windows Subsystem for Linux) - Windows 10 supports Ubuntu or any other Linux distribution natively. This is by far the easiest and fastest option for using OCaml on Windows, and the one that support OCaml most fully.

    The disadvantages of this approach are:

    • By default, you’ll be creating Linux binaries, which can only be run on Linux or on another Windows 10 machine that has WSL activated. However, this can be mitigated by using and following the instructions at opam-cross-windows, which can create Windows OCaml programs from Linux.
    • WSL on Windows has no direct graphical support. It thus requires communication via the X protocol, using an X server such as Xming) on the Windows side. Again, by using opam-cross-windows, this barrier can be eliminated.
  • Similar to WSL above, you can create OCaml programs on Linux proper, and cross-compile them so they work on Windows using opam-cross-windows.

  • OCaml for Windows: A cygwin-based Ocaml distribution, with opam support. Keep in mind that cygwin is a translation layer for unix commands, and thus slows down compilation performance. However, the binaries produced can be run in Windows proper without cygwin, if they’re built with the right compiler (mingw).
    • sys2cyg is a tool that allows you to install up-to-date packages from MSYS2 (a lightweight fork of cygwin). MSYS2 by itself is incapable of building OCaml packages, but has better-maintained libraries, which could be useful for building OCaml libraries.
  • esy: a build tool similar to npm and OPAM created by the Reason community. esy operates on top of cygwin but hides it away, making OCaml feel completely native to windows. It therefore also inherits cygwin’s slow compilation speed. Not all OPAM packages are available yet, but support is rapidly growing.

There is work being put in by OCaml Labs to improve the Windows situtation further. Additionally, OPAM is being extended to support a Windows environment. See this post for details.