Linking error using findlib.dynload

I’m trying to use lwt.unix in a library that will be dynamically loaded. I have a minimal example here https://github.com/philzook58/dynload_fail

Fatal error: exception Dynlink.Error (Dynlink.Cannot_open_dll "Dynlink.Error (Dynlink.Cannot_open_dll \"Failure(\\\"/home/philip/.opam/bappy4/lib/lwt/unix/lwt_unix.cmxs: undefined symbol: caml_mutex_lock\\\")\")")

I see similar issues elsewhere on the internet such as here

I can get my example to work if I change the build arguments of the executable doing the dynamic linking to include lwt.unix, but the actual executable that does the dynlinking has build arguments out of my control. I thought the dynamic linking should be pulling in transitive dependencies, so I feel like the executable doing the dynamic linking shouldn’t need the dependencies of the plugin at compile time.

For future reference, I asked this question on a different forum and it seems like this may be an issue related to a fairly unused C stub in the compiler that should be fixed in newer versions.


1 Like