-
Install MSYS2
-
Install required packages:
$ pacman -S rsync patch diffutils curl make unzip git m4 perl tar mingw-w64-cross-gcc mingw-w64-x86_64-pkg-config
- Add
/opt/bin
to $PATH:
$ echo 'export PATH=$PATH:/opt/bin' >> ~/.bashrc
-
Restart the terminal or do
source ~/.bashrc
-
Download and extract the opam64 archive
$ curl -LO https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2/opam64.tar.xz
$ tar xf opam64.tar.xz
- Run the opam install script. Ignore the messages about missing programs. MSYS2 installs packages differently from Cygwin.
$ bash opam64/install.sh
- Initialize the opam repository and set a default switch.
$ opam init default "https://github.com/fdopen/opam-repository-mingw.git#opam2" -c "ocaml-variants.4.10.0+mingw64c" --disable-sandboxing
- Allow opam to edit
.bash_profile
. (Press y)
Do you want opam to modify C:/dev/msys2/home/Max/.bash_profile? [N/y/f]
(default is 'no', use 'f' to choose a different file) y
- Allow opam to add the hook. (Press y)
A hook can be added to opam's init scripts to ensure that the shell remains in sync with the opam environment when they are loaded. Set that up? [y/N]
- Restart the terminal and you are ready to use OCaml in MSYS2.
These instructions are very old, so it's entirely possible that they don't work anymore.
If you're just trying to install OCaml on Windows follow the official instructions here: https://ocaml.org/docs/ocaml-on-windows