# Dynamic loading a library with Fl\_dynload

**URL:** <https://discuss.ocaml.org/t/dynamic-loading-a-library-with-fl-dynload/7733>\
**Category:** Learning\
**Tags:** dynlink, dune\
**Created:** [April 23, 2021, 7:19pm UTC](https://discuss.ocaml.org/t/dynamic-loading-a-library-with-fl-dynload/7733 "2021-04-23T19:19:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anwar](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@anwar](https://discuss.ocaml.org/u/anwar)\
**Post date:** [April 23, 2021, 7:19pm UTC](https://discuss.ocaml.org/t/dynamic-loading-a-library-with-fl-dynload/7733/1 "2021-04-23T19:19:20Z")

</div>

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?
