Ocamlc -i error: "Unbound module", how to fix it?

4.06

Does anyone know why this error might be caused when trying to generate .mli files for a library?

$ ocamlc -i parallel.ml
File "parallel.ml", line 8, characters 5-9:
Error: Unbound module Util
$ ls util.* 
util.ml  util.mli
$ ocamlc -v
The OCaml compiler, version 4.06.2+dev0-2018-02-16

You need to compile the cmi file for the interfaces used by your compilation unit.

1 Like

Ok, so I should try giving the .cmi as argument to this invocation, this probably can’t follow unit references for some reason (though it looks like a bug since ocamlc can)

WIth ocamlc -i, the compiler merely stops after the typechecking and try to print the inferred signature. However, the earlier parts of the compiler pipeline are the same. In other words, you need exactly the same cmi compiled interfaces in the same included directories that you would need with ocamlc -c for compiling the ml file.