Haskell cabal包括静态库

Tim*_*Tim 5 haskell ffi cabal

我有一个令人尴尬的简单问题.

我正在尝试使用mylib.a一个大型C项目的归档库(称之为)(使用GHC的MinGW副本编译).

从顶层我有:

./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
Run Code Online (Sandbox Code Playgroud)

project.cabal既有

c-sources:           cbits/interface.c
include-dirs:        include
Run Code Online (Sandbox Code Playgroud)

extra-lib-dirs似乎想绝对路径(目录).

如何解决这个问题?

小智 3

答案来自这里https://github.com/haskell/cabal/issues/4677

我想你的档案是 name libmylib.a,然后将其添加到你的 cabal 文件中

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"
Run Code Online (Sandbox Code Playgroud)

您可能还需要指定 gcc 选项-L来指定存档路径