I am trying to create a library that I can use in other OCaml projects, and I'm totally lost.
I'm currently using ocamlbuild
which is great for spitting out executables, but I don't know how to get a library out of it.
I've discovered the -a option in ocamlopt
and ocamlc
but I'm not really sure how to use it. The documentation I've found (for example, here), seems to assume some preexisting knowledge. I don't even know what a .a file is. After I run that, which of the outputted files do I need to build a project that depends on this library? Do I need the mli files so that the application knows the signatures of the library code, or is that included in the output somehow? Also, it would be nice to be able to package all the files together, something similar to a .jar file for Java.
In any case, I would love for ocamlbuild
to do all of this for me, since if I have to invoke ocamlopt -a
I will have to either manually specify dependencies or hack a script around ocamldep
-- something that ocamlbuild
was supposed to fix. However, I don't know how to tell it to build a library.
I'm willing to use oasis or OPAM or something if it's necessary, but I would like to learn how to do this using just the basic tools first.
.mllib
, saylibname.mllib
containing the list of all the modules you'd like to put in your library, and then doocamlbuild libname.cma
to get your library compiled. – Dislike