One year later, take-two on transitioning from make to dune for an OCaml-based PL course. We have a course library, say, code.cma, stored in a folder outside the dune workspace, say /Users/studentX/lib/, several course projects use the definitions in this course library.
As I understand it, the singular "library" in a dune stanza refers to the artifact created by a build (the output) while the plural "libraries" refers to -inputs- to the current build. How to inform dune about the path to look for non-local .cma files? (As in the include switch > ocamlc -I path ...)? I found the following in the dune documentation:
Finding external libraries
When a library is not available in the workspace, dune will look it up in the installed world, and expect it to be already compiled.
It looks up external libraries using a specific list of search paths. A list of search paths is specific to a given build context and is determined as follow:
if the ocamlfind is present in the PATH of the context, use each line in the output of ocamlfind printconf path as a search path
otherwise, if opam is present in the PATH, use the output of opam config var lib
otherwise, take the directory where ocamlc was found, and append ../lib to it. For instance if ocamlc is found in /usr/bin, use /usr/lib
I didn't know what "A list of search paths is specific to a given build context..." meant but ocamlfind -is- present in the PATH and the command
> ocamlfind printconf path
shows
/Users/muller/.opam/default/lib
seems reasonable (though I suppose I should go sort out exactly the difference between a package and a library). Anyway, I couldn't find a more civilized way to extend ocamlfind's search path so I edited /Users/muller/.opam/default/lib/findlib.conf
by hand to include the path to our course library. Dune still cannot find our course library.
I could be wrong, but it seems this setup (with a standard site library code.cma) is pretty common, so I'm sure I'm missing something super-obvious in the documentation. Any leads would be appreciated.
Bob Muller