OCAMLBUILD(1)
π OCAMLBUILD(1) π
okay bestie, welcome to the General Commands Manual entry for ocamlbuild β the OCaml project compilation tool. pull up a chair, grab a strawberry, and let's get you compiling πβ¨
πΈ NAME πΈ
ocamlbuild β the OCaml project compilation tool π
π¦ SYNOPSIS π¦
ocamlbuild [ -Is dir1,... ] [ -libs lib1,... ] [ -lflags flag1,... ]
[ -pp flags ] [ -tags tag1,... ] [ -j parallel-jobs ] target.native
[ -- arg1 arg2 ... ]
(same options)
like, that's the whole vibe. one target, a pile of flags, and optionally some args you're yeeting straight at your own program π«Ά
β¨ DESCRIPTION β¨
so ocamlbuild(1) orchestrates the compilation process of your OCaml project. it's giving make(1) energy, except it's tailor-made to automatically compile most OCaml projects with very little user input. main character energy fr fr π
ocamlbuild should be invoked in the root of a clean project tree β and yes, "clean" means like, no leftover compilation files lying around. no cap. π
give it one or more targets to compile and it:
- scans the required subdirectories to gather info about the various files present
- runs tools such as
ocamldep(1)to extract dependency information - gathers optional files that fine-tune its behaviour
bestie, listen: target names are very significant. iykyk π₯
π TARGET NAMES π
ocamlbuild uses a set of target naming conventions to pick what kind of object to produce. target names look like base.extension where base is usually the name of the underlying OCaml module, and extension says what kind of object to make from that file β a byte code executable, a native executable, documentation... literally whatever β¨
and ofc extensions like .cmo, .cma, .cmi... map to their usual counterparts, as they should π
here's the list of the most important ocamlbuild-specific extensions:
.nativeβ Native code executable π₯.byteβ Byte code executable π¦.inferred.mliβ Interface inferred withocamlc-iπ.docdir/index.htmlβ HTML documentation generated withocamldocπ
π OPTIONS π
the following command-line options are recognized by ocamlbuild(1). yes, there are a LOT. we're doing all of them. no skipping. periodt. π
-versionβ Display the version--versionβ same as-version-vnumβ Display the version number--vnumβ same as-vnum-quietβ Make as quiet as possible π€«-verbose <level>β Set the verbosity level on a scale from 0 to 8 (included)-documentationβ Show rules and flags-log <file>β Set log file-no-logβ No log file-cleanβ Remove build directory and other files, then exit π§Ή-rβ Traverse directories by default (true: traverse)-I <path>β Add to include directories-Is <path,...>β (same as above, but accepts a (comma or blank)-separated list)-X <path>β Directory to ignore π ββοΈ-Xs <path,...>β (idem)-lib <flag>β Link to this ocaml library-libs <flag,...>β (idem)-mod <module>β Link to this ocaml module-mods <module,...>β (idem)-pkg <package>β Link to this ocaml findlib package-pkgs <package,...>β (idem)-package <package>β (idem)-syntax <syntax>β Specify syntax using ocamlfind-lflag <flag>β Add to ocamlc link flags-lflags <flag,...>β (idem)-cflag <flag>β Add to ocamlc compile flags-cflags <flag,...>β (idem)-docflag <flag>β Add to ocamldoc flags-docflags <flag,...>β (idem)-yaccflag <flag>β Add to ocamlyacc flags-yaccflags <flag,...>β (idem)-lexflag <flag>β Add to ocamllex flags-lexflags <flag,...>β (idem)-ppflag <flag>β Add to ocaml preprocessing flags-pp <flag,...>β (idem)-tag <tag>β Add to default tags-tags <tag,...>β (idem)-plugin-tag <tag>β Use this tag when compiling themyocamlbuild.mlplugin-plugin-tags <tag,...>β (idem)-tag-line <tag>β Use this line of tags (as in_tags)-show-tags <path>β Show tags that applies on that pathname-ignore <module,...>β Don't try to build these modules-no-linksβ Don't make links of produced final targets-no-skipβ Don't skip modules that are requested byocamldepbut cannot be built-no-hygieneβ Don't apply sanity-check rules-no-pluginβ Don't buildmyocamlbuild.ml-no-stdlibβ Don't ignore stdlib modules-dont-catch-errorsβ Don't catch and display exceptions (useful to display the call stack)-just-pluginβ Just buildmyocamlbuild.ml-byte-pluginβ Don't use a native plugin but bytecode-plugin-optionβ Use the option only when plugin is run-sanitization-scriptβ Change the file name for the generated sanitization script-no-sanitizeβ Do not generate sanitization script-nothing-should-be-rebuiltβ Fail if something needs to be rebuilt-classic-displayβ Display executed commands the old-fashioned way-use-menhirβ Use menhir instead of ocamlyacc-use-jocamlβ Use jocaml compilers instead of ocaml ones-use-ocamlfindβ Use the 'ocamlfind' wrapper instead of using Findlib directly to determine command-line arguments. Use-no-ocamlfindto disable. Implies-plugin-use-ocamlfind.-no-ocamlfindβ Don't use ocamlfind. Implies-plugin-no-ocamlfind.-plugin-use-ocamlfindβ Use the 'ocamlfind' wrapper for buildingmyocamlbuild.ml-plugin-no-ocamlfindβ Don't use ocamlfind for buildingmyocamlbuild.ml-toolchain <toolchain>β Set the Findlib toolchain to use. The default toolchain is always used for buildingmyocamlbuild.ml.-j <N>β Allow N jobs at once (0 for unlimited)-build-dir <path>β Set build directory (implies no-links)-install-lib-dir <path>β Set the install library directory-install-bin-dir <path>β Set the install binary directory-whereβ Display the install library directory-which <command>β Display path to the tool command-ocamlc <command>β Set the OCaml bytecode compiler-plugin-ocamlc <command>β Set the OCaml bytecode compiler used when buildingmyocamlbuild.ml(only)-ocamlopt <command>β Set the OCaml native compiler-plugin-ocamlopt <command>β Set the OCaml native compiler used when buildingmyocamlbuild.ml(only)-ocamldep <command>β Set the OCaml dependency tool-ocamldoc <command>β Set the OCaml documentation generator-ocamlyacc <command>β Set the ocamlyacc tool-menhir <command>β Set the menhir tool (use it after-use-menhir)-ocamllex <command>β Set the ocamllex tool-ocamlmklib <command>β Set the ocamlmklib tool-ocamlmktop <command>β Set the ocamlmktop tool-ocamlrun <command>β Set the ocamlrun tool--β Stop argument processing, remaining arguments are given to the user program-helpβ Display this list of options--helpβ Display this list of options
π SEE ALSO π
and that's the whole page bestie π you made it to the end, iconic behaviour honestly. this was OCAMLBUILD(1) from the General Commands Manual β go forth and build, and remember: target names are significant, keep your tree clean, and slay β¨π¦π
π¦ where this page comes from
- debian bookworm: ocamlbuild 0.14.1-1 Β· LGPL-2.0-only WITH OCamlbuild exception
- debian trixie: ocamlbuild 0.16.1-1+b1 Β· LGPL-2.0-only WITH OCamlbuild exception
- ubuntu jammy: ocamlbuild 0.14.1-1 Β· LGPL-2.0-only WITH OCamlbuild exception
- ubuntu noble: ocamlbuild 0.14.3-1 Β· LGPL-2.0-only WITH OCamlbuild exception
- ubuntu questing: ocamlbuild 0.16.1-1build1
- ubuntu resolute: ocamlbuild 0.16.1-2build3 Β· LGPL-2.0-only WITH OCamlbuild exception
- ubuntu stonking: ocamlbuild 0.16.1-2build4 Β· LGPL-2.0-only WITH OCamlbuild exception
- Copyright 2007 Institut National de Recherche en Informatique et *)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms