Dune exec, C stubs and CAML_LD_LIBRARY_PATH

Hi, I am using dune to build a project that contains some native code. I used the c_names stanza and everything just worked when I used dune exec bin/main.ml:

$ dune exec bin/main.exe
Hello from C!      
wow!

However, when I try and run the bytecode it all blows up with a missing library:

$ dune exec bin/main.bc
Fatal error: cannot load shared library dlllib_stubs
Reason: dlllib_stubs.so: cannot open shared object file: No such file or directory

After some Googling I found that I needed to set the library path, which worked:

$ CAML_LD_LIBRARY_PATH=_build/default/lib:$CAML_LD_LIBRARY_PATH dune exec bin/main.bc
Hello from C!      
wow!

Is there any way that I can set this automatically with Dune? Thank you :slight_smile:

4 Likes

Eventually, Dune will set this variable itself.

1 Like

The corresponding issue on github: https://github.com/ocaml/dune/issues/108

2 Likes