It took me a while to learn this, but I now understand that “library” is an ocaml term, not just a dune term, and that dune turns a library
stanza into a library file, also called an archive file, which according to the ocaml compiler man page ends with the extension .cmxa
.
I’d like to understand a few things about library depndencies “below” the level of dune itself, i.e. without the abstraction dune provides letting libraries use external libraries. I can’t tell how much is dune and it’s just a thin dune layer on top of plain opam/ocaml/ocamlopt stuff.
-
Is the name of the archive file relevant to ocaml code at all in terms of modules? i.e does the archive file itself implicitly define the top-level module that dune makes available? Or is the top-level module in the archive file? I imagine it’s the latter.
-
When dune turns a
library
stanza into a top-level module in an opam package it builds, that top-level module is then available in a consuming dune project’slibrary
orexecutable
whoselibraries
clause specifies the consumed library’spublic_name
, which must begin with its opam package name. Is thispublic_name
lookup specific to using modules from dune-built projects? Or could I specify a non-dune opam package’s module inpublic_name
to use it in a dune project? If not, how does one use a non-dune package’s modules in a dune project? -
I imagine dune uses a dune-built opam package’s
dune-package
file to resolve what modules are available and how to make them available in compiled ocaml code. Is there a lower-level way to inspect what top-level modules are available in an installed opam package?ocamlobjinfo
looks promising but it’s not clear to me how to interpret its output in terms of how to use a library file’s modules.
Thanks for any help.
2 posts - 2 participants