Reputation: 135
So I am writing a multiple-file program in OCaml and my directory structure looks like this:
src
|- module1.ml
|- section1
|- module2.ml
|- module3.ml
Where module1 opens module2 and module3, and module2 opens module3.
I compile the program with the following:
ocamlopt -o bin/myprog src/module1.ml src/section1/module2.ml src/section1/module3.ml
It throws in error in module2.ml saying that Module3 is unbound.
Does anyone know why this is happening?
Upvotes: 1
Views: 373
Reputation: 1596
First, note that the order in which .cmx and .ml arguments are presented on the command line is relevant. This means that module1 which appears to be using both module2 and module3 should be in last position and not first as you're doing here.
You will also need to add the -I directory
option to add the given directory to the list of directories searched for.
This should do the job:
ocamlopt -o bin/myprog -I src/section1 src/section1/module3.ml src/section1/module2.ml src/module1.ml
Upvotes: 1