Compile OCaml code without leaving behind temporary files.
The OCaml compiler often generates intermediate files during compilation, which developers must clean up manually.
This project provides three lightweight shell scripts — ocaml-std, ocaml-core and ocaml-js — that compile OCaml code in a system temporary directory and automatically remove all intermediate files once the build is complete.
- Clean builds: Produces native executables without leaving behind
.cmi,.cmo, or other temporary artifacts. - Multiple targets:
ocaml-std→ build with the OCaml standard library onlyocaml-core→ build with Jane Street’s Base, Stdio, and Core librariesocaml-js→ build JavaScript output viajs_of_ocaml
- Simple usage: Just provide your source files — the scripts take care of the rest.
- OCaml
4.14.4+(recommended) opamcppo
Includes the native requirements, plus:
basestdiocoreocamlfind
In the updated ocaml-clean-compile, ocaml-core is simply a thin wrapper around ocaml-std.
If you need to include additional packages, use the following command instead:
$ ocaml-std -r requirement.txt lib1.ml ... main.mlRemember to list all dependencies in requirement.txt again, including base, stdio, core, and any other required packages.
Includes the native requirements, plus:
js_of_ocamljs_of_ocaml-ppxocamlfind
$ ocaml-std lib.mli lib.ml main.ml$ ocaml-core lib.mli lib.ml main.ml$ ocaml-js lib.mli lib.ml main.ml$ ocaml-std -r requirement.txt lib.mli lib.ml main.mlList each dependency on a separate line in requirements.txt.
Refer to core.txt for formatting guidance.
This project does not aim to replace dune.
dune remains the recommended build system for managing complex OCaml projects.
ocaml-clean-compile is intended only as a lightweight helper for quick compilation without clutter.
inplace is bundled for cppo in-place editing.
MIT License (c) 2026 ByteBard