Skip to content

Instantly share code, notes, and snippets.

@Pirgosth
Last active November 17, 2020 18:19
Show Gist options
  • Save Pirgosth/176104e18b6d026626c2dc62eccd836d to your computer and use it in GitHub Desktop.
Save Pirgosth/176104e18b6d026626c2dc62eccd836d to your computer and use it in GitHub Desktop.
Short guide on how to install Ocaml on Windows
@Pirgosth
Copy link
Author

Pirgosth commented Sep 30, 2019

How to install Ocaml on Windows ?

Install required files

First, you'll need to dowload and run the installer that can be find right here:

Follow installer instructions, and keep installation path in mind.
Installation can take a while, as it need to download all dependencies (Install take at least 1,84Go, so be sure to have enough free space).

Add install path to PATH

Now you'll have to add Ocaml installation path in Windows PATH, to make it available anywhere.
To do this, you'll need to search for Environnement Variables settings, and go into Environnement variables tab.

This menu must appear:
pic2

Now you'll need to add two variables: simply click new, and put:

  • OCAMLLIB for var name, and %Your_Install_Path%\home\%Your_User_Name%\.opam\ocaml-variants.4.08.0+mingw64c\lib\ocaml as value
    For Exemple mine is C:\OCaml64\home\Pierre\.opam\ocaml-variants.4.08.0+mingw64c\lib\ocaml
  • PATH (if it does not already exists) and add %Your_Install_Path%\home\%Your_User_Name%\.opam\ocaml-variants.4.08.0+mingw64c\bin

pic3

Once you finished, simply confirm changes by clicking OK, you're done with Environnement variables.
You must now be able to run Ocaml by typing ocaml in a cmd shell and see it working:

pic4

Make Sublim Text 3 working with Ocaml

You just need to add a new build system, in Tools>Build system>New Build System.
It will create a new file like this:

pic5

And replace its content with the following:

{
    "shell_cmd": "ocaml $file",
    "selector": "source.ocaml",
    "working_dir": "$file_path"
}

Finally, push ctrl-S and create a new folder called Snippets, and save your new build system into it, as Ocaml.sublime-build
pic6
You can now execute Ocaml code within Sublim Text just by pressing ctrl-B.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment