Installing OCaml on Windows
This page is quite long, as I had a hard time, and as they were a lot of tutorials that finally worked for me, yet none of them were enough so that I could fully enjoy OCaml in my editor (so I'm making my own plugin for IntelliJ 🚀).
You can use a WSL
👍: easy, you got a graphical version for emacs, sublime text, IntelliJ, etc.
👎: not beautiful, a bit blurry
This is Linux on Windows. Here is the tutorial to install a WSL. Then you can install OCaml like you would on Linux.
sudo apt-get update && sudo apt-get install ocaml # editor: sublime text sudo apt-get install sublime-text subl -c # editor: emacs sudo apt-get install emacs emacs -c # editor: IntelliJ # ... get the tar.gz on their Website, tar xvf idea.tar.gz # inside the bin folder, run the .sh ./idea.sh -c
OCaml from "sources"
👍: easy, VSCode+tuareg
👎: you need someone to zip their working OCaml for you
The original tutorial is made by my teacher is here, but just in case, here is a copy.
- Download the zip for ocaml 4.08
- extract in
- open a terminal
C:\ocaml\bin\ocamlc.exe -v(expected: ocaml version)
PATHin the Windows search bar (bottom left)
- "edit environment variables" then "Environment variables" button
- In the first panel, click on
Paththen modify (right below)
- add this entry:
- open a new terminal and write
- same output as
Then you can use it in any terminal, like in VSCode, using the tuareg mode plugin (as my teacher is explaining).
OCaml in IntelliJ (WSL)
👍: easy setup
👎: no tuareg mode, the plugin do not have many features.
You can install OCaml plugin on IntelliJ, and compile using a WSL.
Install a WSL
This is the official tutorial to install a WSL, but if this looks complicated to you, here is what I did
- open the Windows Store
- enter "Debian" (or "Ubuntu")
- install it
- start it, once the initialization is done, you are good
To compile, simply click on "Terminal" (the Bar at the bottom, with Git/TODO/...). Click on the small caret-down icon and select Debian. Then, simply write your commands 🚀.
# install OCaml, once $ sudo apt-get install ocaml # check installed $ ocaml --version # compile $ ocamlc src/hello_word.ml # run $ ./a.out Hello, World!
OCaml in IntelliJ (Cygwin)
👍: easy setup, Makefile
👎: same as WSL
- Install from the internet, Next
- Next, Next, Next
- Pick a link in the list, Next
- In view, select full
Now, you have to pick the commands you want, which means replacing "Skip" (in the column "New") with a version of the command. You should use the search bar.
I picked make, ocaml, opam (not required), vim (just in case), wget and curl. If you are planning to use opam, add
- Then process with the installation
Now, you should open a new terminal on Windows (ex: Powershell, cmd, ...) and write a command
$ make -v # GNU Make 4.3 # ...
You may have to restart your IDE (if you are using one), or your computer. If this is still not working, check that
C:/cygwin64/bin is in the PATH.
Now you can write a Makefile in IntelliJ, and compile using Make.
OCaml in IntelliJ (tricks, node.js)
👍 and 👎: see the README.md
Every setup before was easy, because I removed any setup complicated. But, if you want more, you need to dig more into it.
- check esy
- or check opam with maybe this installer OCaml+Windows (discontinued since August 2021)
- or you could check dune
Do not look for the ghosts
They are still in the official documentation (or in some online tutorials), but they disappeared 👻.
- WinCaml: dead, the links are directing to the discontinued installer of the previous section
- OCPWin: it disappeared