Compiling ocaml dune project dynamically with 3rd party code

Hello,

I am writing a project that is using another ocaml project (let’s say GitHub - mirleft/ocaml-tls: TLS in pure OCaml).

I am able to compile my code, but looks like it is compiled statically. And from what I understand - usually ocaml is compiled statically (to another ocaml).

What I want is -

  1. compiling the 3rd party project to some shared library
  2. compiling my code dynamically so I will be able to change the implementation of the 3rd party code without recompiling my binary.

I am new to ocaml and after few hours of tries I still have no idea what should I search for.

Can someone please help me figuring out how can I find the relevant information for what I described above? Maybe some known project that does it or a dune file example

Thank you!

One search keyword would be “plugins” – in the sense of ocaml_plugin · OCaml Package – although that’s a very general solution so maybe there are less heavy-weight ones.

Edit: ocaml_plugin is a bad idea though because it is meant for from-source dynamic loading. The underlying Dynlink works with .cmxs files, not sure how hard it would be to integrate with e.g. Dune-level packages, but probably not so easy.