# Dynlinking plugin which references LLVM stubs

**URL:** <https://discuss.ocaml.org/t/dynlinking-plugin-which-references-llvm-stubs/12596>\
**Category:** Community\
**Tags:** llvm, dune\
**Created:** [July 11, 2023, 4:11pm UTC](https://discuss.ocaml.org/t/dynlinking-plugin-which-references-llvm-stubs/12596 "2023-07-11T16:11:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kakadu](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/kakadu/32/1204_2.png) [@Kakadu](https://discuss.ocaml.org/u/Kakadu)\
**Post date:** [July 11, 2023, 4:11pm UTC](https://discuss.ocaml.org/t/dynlinking-plugin-which-references-llvm-stubs/12596/1 "2023-07-11T16:11:25Z")

</div>

I’m following dune’s manual about creating dynamically loadable plugins [How to Load Additional Files at Runtime — Dune documentation](https://dune.readthedocs.io/en/stable/sites.html#plugins-and-dynamic-loading-of-packages)

When my plugin depends on Unix library it loads fine. But when I reference Llvm instead of Unix, it can’t load a plugin, saying.

Fatal error: exception Dynlink.Error  
(Dynlink.Cannot\_open\_dll “Dynlink.Error (Dynlink.Cannot\_open\_dll "Failure(\"/home/kakadu/asp/dune-sites-demo/\_build/install/default/lib/plugin1/plugin1\_impl/plugin1\_impl.cmxs: undefined symbol: llvm\_build\_add\")")”)

The demo is [here](https://github.com/Kakadu/dune-sites-demo/tree/llvm). Any ideas?

P.S. I want to mention @alan who’s working on new Llvm release.

---

<div class="post-metadata">

**Author:** ![Kakadu](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/kakadu/32/1204_2.png) [@Kakadu](https://discuss.ocaml.org/u/Kakadu)\
**Post date:** [July 25, 2023, 1:01pm UTC](https://discuss.ocaml.org/t/dynlinking-plugin-which-references-llvm-stubs/12596/2 "2023-07-25T13:01:46Z")

</div>

> <https://github.com/Kakadu/dune-sites-demo/tree/llvm/findlib>
>
> //github.com/Kakadu/dune-sites-demo/tree/llvm/findlib

I wrote the same with ocamlfind+dynlink and it works even with LLVM.  
It looks like dune uses other kind of machinery, where linking with LLVM doesn’t works as is. Any help?

---

<div class="post-metadata">

**Author:** ![alan](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@alan](https://discuss.ocaml.org/u/alan)\
**Post date:** [July 25, 2023, 2:34pm UTC](https://discuss.ocaml.org/t/dynlinking-plugin-which-references-llvm-stubs/12596/3 "2023-07-25T14:34:42Z")

</div>

I don’t know what is going on and have never mucked deep into plugins, but I do know that Dune is missing a bunch of features that may [impede](https://discuss.ocaml.org/t/improving-interoperability-between-ocaml-ocamlfind-and-dune/4479/16) interaction with findlib-based libraries. For example, the versions of LLVM on opam make use of a [“predicate”](https://github.com/ocaml/opam-repository/blob/master/packages/llvm/llvm.14.0.6/files/META.patch) to enable static linking to LLVM. OCamlbuild permits users to access this option, but [Dune does not](https://discuss.ocaml.org/t/using-output-of-ocamlfind-params-only-show-in-a-dune-build/4187/8). This is a concern that @kit-ty-kate has mentioned while she has been trying to make the LLVM bindings build with Dune.

However, you don’t seem to need the llvm.static predicate (you would probably _not_ want this flag), so I’m not sure what the issue is for your case specifically.
