These instruction shows a procedure to install native OCaml binaries in Windows. If your operative system is Windows 10 (Insider Preview) build 14316
or later you can also install OCaml through Bash on Ubuntu on Windows. In this case, follow the instruction to install OCaml on Ubuntu.
Download OCaml official distribution. It contains both OCaml compilers and Opam packet manager. Suppose you have installed the software in C:/OCaml
. To be sure you've correcly installed OCaml open cmd.exe
and type ocaml
.
If you see the message 'ocaml' is not recognized as an internal or external command, operable program or batch file
you need to add C:/OCaml/bin
to your Path (Environment Variable).
in Control Panel > System and Security > System > Advanced system settings (on the left) > Environment Variables
and then select Path
in System Variable
tab, then Edit
.
Add C:/OCaml/bin;
to the list.
Without Cygwin you can't use Opam. In fact, if you try to open Opam typing opam
in cmd.exe
it shows a message: Fatal error: exception Unix.Unix_error(20, "create_process", "cygcheck")
.
Download Cygwin and start the installer. Be sure to check the following packages:
Suppose you have installed the software in C:/cygwin
(C:/cygwin64
for 64bit version). Open cmd
and type wget
(or one of the executable present in C:/cygwin/bin
) to check if you can use the Cygwin executables. If the executable won't open, add C:/cygwin/bin
to your Path (Environment Variable).
Open cmd.exe
and type opam init
to configure Opam.
Then install ocamlfind
(part of the OCaml compiler) with
opam install ocamlfind
opam config env
Check if ocamlfind
is installed typing it in cmd.exe
.
The command opam config env
is used to add opam
's executables directory to the enviroment path. If after logout you cannot reach ocamlfind
anymore, you can manually add it adding to path the following line: C:/Users/<your user>/Documents/.opam/system/bin/
.
Packages are installed through Opam with the command opam install xyz
where xyz
is the name of the package.
Try running the command opam install utop
. If you have no errors, then typing utop
will open the executable.
If you see the message
[ERROR] The compilation of zed failed at "ocaml setup.ml -build".
you have to manually install the single packages. Try again typing:
opam install zed
opam install lambda-term
opam install utop
Both lambda-term
and utop
might not install. See Troubleshoot section.
You can install core
package with opam install core
. On Windows 64bit version (and 64bit Cygwin) you will see the following error:
[ERROR] core is not available because your system doesn't comply with os != "win32" & ocaml-version = "4.02.3".
If package with name xyz.10.1
fails to install (where xyz is the name of the package, and 10.1 its version) with the following message:
install: cannot create regular file '/cygdrive/c/Users/<your user>/Documents/.opam/system/bin/<something>': File exists
You have to go in this directory:
C:\Users\<your user>\Documents\.opam\repo\default\packages\<xyz>\<xyz.10.1>\files
and delete the file xyz.10.1.install
.
If you try to open some Opam's package (eg: utop
) and you see this error:
Fatal error: cannot load shared library dlllwt-unix_stubs
Reason: The specified module could not be found.
Run opam config env
again and try to reopen the executable.