How to install ocaml on Mac



If you want to play with the language, I would recommend:

opam install utop

which will install a very nice interpreter for ocaml. Then you can do:


and start typing in OCaml expressions:

utop # 1 + 4;;
- : int = 5

For compiling OCaml applications I would recommend the dune build system.


See also:


If you just want to see if your OCaml toplevel is working you can do a quick test from the terminal:

$ ocaml
        OCaml version 4.06.0
# 1 + 4;;
- : int = 5
# exit 0;;

(The ;; token tells the toplevel to evaluate what you’ve typed since the last evaluation.)


hi, can you help me? I use Mac with the system 10.13.6. But I can’t install Graphics package, how can I install it? I have tried lots of methods, but failed…thanks