OCaml on Windows

Full support for OCaml on Windows is actively being worked on and a workable environment can already be achieved today. A gentle reminder that if you do not need Windows binaries, then a more stable option is to use WSL2. This is described on the up and running page.


opam-repository-mingw is an opam repository containing patches for packages to build and install on Windows as well as mingw-w64 and MSVC compiler variants (in both 32 and 64-bit). For a long time this has been maintained by @fdopen along with installers to create a custom Cygwin environment with opam and OCaml installed.

As of August 2021, the repository will no longer be updated. It is still useful as an overlay to the default opam repository. This means if a package exists in opam-repository-mingw the opam client will use that information, otherwise it will fall through to opam-repository. To add opam-repository as an underlay to your opam setup (assuming you followed the manual installation from the OCaml for Windows site), you can use:

opam repo add upstream https://opam.ocaml.org --rank 2 --all-switches --set-default

This assumes you only have the opam-repository-mingw repository for this switch set with a priority of 1.


After the successful release of opam 2.1.0 the next version of opam will focus on closing the gap to fully supporting Windows. This includes supporting external dependency installation for Windows and integrating with the Windows shell. From an opam-repository perspective, the ocaml-base-compiler packages will need to support the mingw-w64 and MSVC variants.

Docker Images

The ocaml/opam Docker Hub repository now contains regularly updated Windows images. This includes images using msvc and mingw. If you are comfortable with Docker, this might be an easier way to get a working Windows environment on your machine.

Help Improve Our Documentation

All OCaml docs are open source. See something that's wrong or unclear? Submit a pull request.