I’m using ocaml 4.12.0 on a Mac, and the Unix standard library doesn’t appear to exist. For example, typing “Unix.time;;” to the prompt results in “Error: Reference to undefined global `Unix’”. Do I need to do something to load it?
If you are using dune, remember to add unix as a dependency. If you aren’t using dune make sure you add the UNIX.cma as described here: The Unix Module
Yes: you can load it by passing the name of the
.cma archive on the command line, eg:
Thank you. That solves the problem when I’m running ocaml interactively.
Thank you. That solves the problem when I’m compiling the ocaml program.
Interactively, you may also use the directive
#load "unix.cma";; if you didn’t put it initially on the command line and don’t want to restart the toplevel.