I've been working on a Haskell library package which requires a custom .dll and .lib on Windows to talk to some OS APIs. The .lib is linked into the library with the extra-libraries
field and the DLL is installed in the cabal package directory with data-files
.
For some reason (I'm not an expert on linking by any means, but this seems weird) if I create a test executable which uses my package (in the build-depends
field), it wants to link in the same .lib used to compile the library - even though it's just calling library functions, not anything the .lib exposes. Obviously it needs access to the .dll at runtime but that is to be expected. Needing the .lib as well seems odd.
I would expect that the .lib would already be linked into the .a file generated by Cabal/GHC for my library when it's installed. Is this not the case? And if it is, can someone explain why it's that way?
ld -r
instead ofar
for vanilla libraries? I've tried addingld-options: -r
but it doesn't seem to do anything (presumably becauseld
isn't being used?) – Salivate