Creating Libraries to Structure a Project with Dune

TL;DR

Add a library stanza in your dune file.

Creating a library with dune is as simple as adding a library stanza in your dune file:

(library
 (name <name>)
 (public_name <public_name>)
 (libraries <libraries...>))

Where <name> is the name of the library used inside internally, <public_name> is the name of the library used by users of the package and <libaries...> is the list of libraries to link to your library.

Note that if the library does not have a public_name, it will not be installed when installing the package through opam. As a consequence, you cannot use an internal library that does not have a public_name in a library or executable that has one.

Help Improve Our Documentation

All OCaml docs are open source. See something that's wrong or unclear? Submit a pull request.

OCaml

Innovation. Community. Security.