makefile - What is the preferred way to structure and build OCaml projects? -


it unclear newcomers ecosystem canonically preferred way structure , manage building small medium sized ocaml projects. understand basics of ocamlc, &c.--they mirror conventional unix c compilers enough seem straightforward. but, above level of one-off compilation of individual files, unclear how best manage compilation , cleanly. issue not searching potential tools, seeing 1 or few right (enough) ways--as validated experience of community--for structuring , building standard ocaml projects.

my model use case modest nontrivial project, of pure ocaml or ocaml plus c dependency. such project:

  1. contains number of source files
  2. links number of standard libraries
  3. links 1 or more 3rd party libraries
  4. optionally includes c library , ocaml wrapper subproject (though managed separately , included 3rd party library, in (3))

several alternative tools stand out:

  • custom makefiles seem common standard in open source ocaml packages, appear frustratingly verbose , complex--even more modest c/c++ projects. worse, many seemingly simple ocaml libraries layer autoconf/automake on top greater complexity.
  • ocamlbuild appears offer modern, streamlined mechanism automating builds minimal configuration, not documented newcomers, nor represented example in introductory materials in ocaml ecosystem, nor visibly used of various published ocaml projects have browsed inspiration.
  • oasis seems layer of convention , library code atop other build systems support building package manager , library, cabal.

(i have seen omake, appears self-styled "make++" includes suite of standard rules common languages, including ocaml, , ocaml-make née ocamlmakefile, providing template of standard rules gnu make.)

are of these preferred, modern way of managing ocaml builds?

how project files best structured?

how 3rd party library dependencies included , managed? preferred install them @ system level, or there standard , straightforward way of managing them locally project? prefer model in projects remain self-contained possible.

you've got thorough listing of options available, question not have clear answer. personal recommendation use ocamlbuild. myocamlbuild.ml file provided here start. allow compile projects depend on various libraries. don't think handles case of binding c libraries, there additional examples on wiki may help.

some people object ocamlbuild because yet build tool, complicating package managers jobs. however, ease of use , fact included in official distribution making more , more used.

you can skip , use oasis directly. new, , stable release has not yet been announced, usable. generate myocamlbuild.ml automatically you. way go in near future, if not already. furthermore, using oasis, have benefit of oasis-db, cpan system ocaml under development.

regarding managing libraries, answer ocamlfind. if have multiple instances of ocaml installed, calling appropriate copy of ocamlfind automatically cause references libraries particular instance, assuming use ocamlfind systematically libraries. use godi install ocaml , libraries. uses ocamlfind, , have no problem having multiple instances of ocaml installed.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -