The latest version of OCaml is 4.04.0. For more information about this release, see the 4.04.0 page.
The OCaml compiler and libraries can be installed in several ways:
- With OPAM, the OCaml package manager (recommended).
- With a system package manager supported by your platform (FreeBSD, Linux, macOS, OpenBSD, Windows)
- In your browser.
- By compiling the source.
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
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
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.
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-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:
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
setuptool. The compilers generate executables that do require Cygwin (
The following pages allow to directly try snippets of OCaml in your browser:
- Try OCaml by OCamlPRO.
compiled by the
- IOCamlJS has OCaml toplevels with interactive notebook functionality.