Install OCaml

The latest version of OCaml is 4.07.0. For more information about this release, see the 4.07.0 page.

The OCaml compiler and libraries can be installed in several ways:

For finding and installing OCaml libraries, see the libraries page. Information about the different versions of OCaml is available on the releases page.


OPAM is the package manager for OCaml. It is the recommended way to install the OCaml compiler and OCaml packages. Simply follow the OPAM install instructions.


pkg_add -r ocaml-nox11 # If you don't want X11 support 
pkg_add -r ocaml


Most Linux distributions allow OCaml and/or OPAM to be installed directly through the system package manager.


apt install ocaml-nox # If you don't want X11 support
apt install ocaml

Other Debian packages related to OCaml are listed here. They are made available through The Debian OCaml Packaging Policy.


apt install ocaml-nox # If you don't want X11 support.
apt install ocaml

Other Ubuntu packages related to OCaml are listed here.


dnf install ocaml
dnf search ocaml   # List packages related to OCaml

OCaml packages are packaged according to this policy. There is an OCaml Special Interest Group and a mailing list for people interested in OCaml on Fedora or Red Hat Enterprise Linux.

Centos / Red Hat Enterprise Linux

yum install ocaml
yum search ocaml   # List packages related to OCaml


With a user that is a member of the portage group do:

emerge dev-lang/ocaml
emerge -S ocaml # List packages related to OCaml


zypper install ocaml


urpmi ocaml-compiler
urpmi ocaml-x11           # To install X11 support
urpmq --list | grep ocaml # List OCaml packages

The Mageia OCaml packaging policy.

Arch Linux

pacman -S ocaml

Other Arch Linux packages related to OCaml are listed here.


On macOS OCaml and/or OPAM can be installed via the existing third-party package systems.


brew install ocaml
brew install opam 


apt install ocaml


port install ocaml
port install opam


pkg_add ocaml
pkg_add opam


Under Windows, the following direct solutions are available to use OCaml:

  • OCaml for Windows provides an experimental OPAM repository and opam build for Windows.

  • OCPWin is a self-contained binary distribution of OCaml for Windows. Some additional features have been added to OCaml for better support of Windows, such as auto-detection of MSVC and support for MSVC 9.0, 10.0, 11.0, 12.0 and 14.0 (VS2015).

Here are a few other alternatives:

  • The OCaml source distribution directly supports many different Windows ports. You will have to compile from source. See the README.win32 file included in the distribution for details.

  • Use « Bash on Windows » and install OCaml as on Ubuntu. Main OCaml versions and OPAM work. The disadvantage of this method is that you don't build native Windows binaries but Linux binaries. See tutorial.

  • Cygwin-based port. Requires Cygwin, you can install them using the setup tool. The compilers generate executables that do require Cygwin (cygwin1.dll).


The following pages allow to directly try snippets of OCaml in your browser:

From Source

Download an OCaml release or the development version and follow the instructions included therein.