Foreign_archives in dune really seem to want a dll

I’m trying to include my self-built library (let’s call it libx.a), but when I include it in a “foreign_archives” stanza (foreign_archives ../my-library/x), dune really wants a dynamic library “dllx.so”, in addition to the static one. I wasn’t able to convince it otherwise, even with “disable_dynamically_linked_foreign_archives”.
Does anyone have any experience with this?

Yes, this is because a DLL is typically needed to link your library into pure bytecode executables. If you don’t care about bytecode, you can add (modes native) to your stanza.

Cheers,
Nicolas

2 Likes

Ah that’s interesting. That works when I don’t have a ctypes stanza, but it seems like dune ctypes requires a bytecode build

(library) will also try to make a cmxs file for dynlinking, which requires a dynamic version of the foreign archive. You can disable this by adding (no_dynlink) to the stanza.

I’m also having this issue with dune 3.6 and ctypes stanza on win platform. Does ctypes stanza require dynlinked library? Is it possible to use ctypes and link it statically to the executable?