The ocamlfind
utility is a great tool to automatically add libraries during compilation, which exempts developers to pass directly the paths to those libraries, e.g., instead of doing
$ ocamlc -I ~/.opam/4.06.0/lib/thepackage -o prog prog.ml
we do
$ ocamlfind ocamlc -package thepackage -o prog prog.ml
cool. This works for 3rd party packages found via
$ ocamlfind list
but what about packages distributed with OCaml, like unix
, which are also listed via the previous command? For example, if my program at the beginning does
open Unix
open Uutf
compiling it by passing unix
and uutf
in the package option to ocamlfind
, works for uutf
but for unix
gives the result
$ ocamlfind ocamlc -package unix,uutf -o prog prog.ml
File "prog.ml", line 1:
Error: Required module `Unix' is unavailable
Only if I do
$ ocamlfind ocamlc -package uutf unix.cma -o prog prog.ml
it works, which seems at least “strange” …
Everything listed by
$ ocamlfind list
should be searchable by this tool when passed via -package
option.
What am I doing wrong?