I have multiple compilation units in OCaml, one of which is causing a few problems. One compilation unit has two files foo_one.mli and foo_one.ml, these compile without any errors when using ocamlc. The other compilation unit has two files shoo.mli and shoo.ml. shoo.ml needs to make use of functions from foo_one, and so in the file shoo.ml I use open Foo_one. To compile, I use the command ocamlc foo_one.mli shoo.mli shoo.ml and the compiler returns the error: Module Foo_one is unavailable (required by Shoo).
What is causing this error and how can it be solved?
I made sure that the compilation units are all in the same directory, with the files in one compilation unit having the same name and capitalising the name of the module I am including in shoo.ml.
Assuming you've compiled
foo_one.mliandfoo_one.mlwith:Then you should be compiling
shoo.mlwith:If you had provided the
-coption, you could compile with the following because you're not yet linking the two, and thusShooonly needs to know the interfaceFoo_oneexposes.If you did this, you could finally link the two together to create an executable with: