Intended use of lib{caml,asm}run_shared.so

I have not found these mentioned in the manual. But by trial and error I found that in order to make a byte code exec that links to a c lib (dllfoo.so, without -custom), I need to link my dllfoo.so against libcamlrun_shared.so.

Is this just something nobody does? Does dune support it? Am I doing it wrong?

P.S. I’m using bazel to generate my build cmd lines, but I think it’s a general build question.

P.P.S. so my inference is that this is the intended use of these shared runtime libs. Yes? Any other uses?

1 Like

These libraries are typically used in conjuction with the -output-obj flag. This flag produces an .c, .o or .so file containing OCaml code in a way that can then be embedded in a main program written in, say, C. Such a program will also need to be linked with the OCaml runtime (the lib{caml,asm}run libraries), and both static and dynamic linking are possible.

Dune does not have special support for -output-obj, only for -output-complete-obj, which is similar but includes the runtime in the final artifact (so that it does not need to be linked separately).

Cheers,
Nicolas

1 Like