I have an embarrassingly simple question.
I am trying to use an archive library (call it mylib.a
) with a large'ish C project (compiled with GHC's copy of MinGW).
From the top level I have:
./project.cabal
./src/...haskell..code...
./cbits/interface.c (simplifies access to `lib.a`)
./include/mylib.h
./lib/mylib.a <<<<<<<<<<<<<<< not sure where to put this or how to reference it
The project.cabal
has both
c-sources: cbits/interface.c
include-dirs: include
The extra-lib-dirs
seems to want an absolute path (directory).
How does one solve this?
The answer is from here https://github.com/haskell/cabal/issues/4677
I suppose your archive is name libmylib.a
, then add this in your cabal file
ghc-Options: -pgml gcc "-optl-Wl,--allow-multiple-definition" "-optl-Wl,--whole-archive" "-optl-Wl,-Bstatic" "-optl-Wl,-lmylib" "-optl-Wl,-Bdynamic" "-optl-Wl,--no-whole-archive"
you might also need to specify the gcc option -L
to specify the archive path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With