How to run a locally-modified OCaml from its build directory?

I’m working on some additional library code. At the moment I run “make” and then “opam install -w .” before I can test my change. The latter command takes a long while since it recompiles all of OCaml. Surely there is a shortcut that’s faster. What is it?


What I do is to run ./configure --prefix $(pwd)/local and then I use the usual install command make install. Then one can run the compiler directly from local/bin.

You can also run the freshly built compiler without installing it, but you will need to pass the stdlib directory by hand, ie ./ocamlc.opt -I stdlib if standing at the root of the tree. If you are running bytecode binaries, you will need to use the right ocamlrun: ./runtime/ocamlrun ./ocamlopt -I stdlib, etc.


1 Like