I am trying to dynamically load a library (noted as A below) in my non-public application that uses dune as the build tool.
I have the following modules:
lib: links library A statically
register: registers the dynamically loaded module
main: dynamically loads lib, and calls the registered functions of A.
This works. However, in main, I wanted to ‘open module’ from the loaded library A, which I cannot do, because the module is a unbound in main.
I have another problem. To register the loaded module A, I need its interface in the register module. To create a side effect to register the module, I also need a dummy instance of the module A. For example: if I want to register
int, I need to do
ref 10, but I don’t have the 10, the implementation of the interface.
I don’t think this is a unique problem. How do people use the dynamically linked libraries?