[Haskell-cafe] Issues with static linking of a C ".a" library with cabal

Hécate hecate at glitchbra.in
Mon Dec 11 08:31:02 UTC 2023


Hi everyone,

I'm hitting a number of roadblocks while trying to embed a ".a" file 
(and its headers) in Haskell code.

The setup is the following: I have a bindings library that handles all 
of the cAPI FFI declarations, and a consumer that does not directly 
depend on the underlying C library.

As such, I use a combination of extra-bundled-libraries, include-dirs 
and install-includes stanzas in my cabal file:

elifflag(bundled-libsodium)
extra-bundled-libraries: Csodium
include-dirs: include
install-includes:
include/sodium.h
include/sodium/core.h
include/sodium/crypto_aead_aes256gcm.h
[…]

(full file here: 
https://github.com/haskell-cryptography/libsodium-bindings/blob/37-libsodium-vendoring/libsodium-bindings/libsodium-bindings.cabal)

It all seemed to work on my day-to-day system, but further tests on a 
system that did not have libsodium installed system-wide showed that 
there's still a missing part:

|/usr/bin/ld.gold:error:cannotfind-lsodium 
collect2:error:ldreturned1exitstatus `gcc'failedinphase`Linker'.(Exitcode:1)|

At this point I am simply baffled, because I thought that I had the 
right invocation for all of this to work.

What else can I do? Am I missing something obvious?

I have opened a ticket here with a bit more details: 
https://github.com/haskell/cabal/issues/9509

Cheers,

Hécate

-- 
Hécate ✨
🐦: @TechnoEmpress
IRC: Hecate
WWW:https://glitchbra.in
RUN: BSD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20231211/3c97ee3f/attachment.html>


More information about the Haskell-Cafe mailing list