Install OCaml

The latest version of OCaml is 4.03.0. For more information about this release, see the 4.03.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-get install ocaml-nox # If you don't want X11 support
apt-get install ocaml

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


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

Other Ubuntu packages related to OCaml are listed here.

Ubuntu's official repositories often lag substantially behind the latest official releases of OCaml and OPAM. More recent versions are made available in these PPAs.

They can be installed with:

add-apt-repository --yes ppa:avsm/ppa
apt-get update -qq
apt-get install -y opam
eval $(opam config env)

Please note PPAs are not reviewed by Ubuntu's security team and you are trusting the PPA's distributor by adding them to your system.


yum install ocaml
yum 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.


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.


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


brew install ocaml
brew install opam 


apt-get 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:

  • Official OCaml distribution. A self-installer with a preliminary version of OPAM 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).

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

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.

  • 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.