Zulip Chat Archive
Stream: lean4 dev
Topic: Building shared dynamic libraries with dependencies
Kiran (Nov 30 2025 at 00:41):
Suppose I have two lean libraries:
- liba
- libb
where liba is standalone, and libb requires liba
both liba and libb have defaulttargets and defaultfacets setup to produce a shared library:
name = "libb"
version = "0.1.0"
defaultTargets = ["Libb"]
[[require]]
name = "Liba"
path = "../liba"
[[lean_lib]]
name = "Libb"
defaultFacets = ["shared"]
This works like I want, save for the fact that the libb.dylib shared library fails to be dlopened unless I have manually dlopened liba.dylib.
How can I:
a) somehow embed the dependency of liba.dylib into the dynamic library for libb.dylib (I have a hard constraint that libb.dylib must be dynamically loaded via dlopen, so either statically linking liba in, or
b) providing appropriate path inside the shared library such that liba.dylib can be found by dlopen.
Furthermore, I'd like to export liba as a library to external users, so they can require it. I'd like to minimise the amount of extra changes they'd have to make to their repo.
Last updated: Dec 20 2025 at 21:32 UTC