I've created test project for cabal library. And I'm trying to build simple project (with only 3 .hs files with using FFI).
HCabalTestLib.cabal file is the next:
library
exposed-modules: Main, Parser.Template, Parser.Data
build-depends: base ==4.6.*
extensions: ForeignFunctionInterface
Then, I use next commands: runhaskell Setup.hs configure runhaskell Setup.hs build
Cabal build procedure successfull create Main_stub.h header file with my FFI declarations and libHSHCabalTestLib-0.1.0.0.a As I understand, libHSHCabalTestLib-0.1.0.0.a is static library (I use Windows).
Finally, I want to use this in simple MS Visual Studio project. I copy header file in project folder, and copy library file (libHSHCabalTestLib-0.1.0.0.a) in the same folder. In Project Properties -> Linker -> Input -> Additional Dependencies I specified my library.
After "Build" my project I've got a lot of linker error:
1>CabalStaticLibExperiment.obj : error LNK2019: unresolved external symbol _hs_init referenced in function _main
1>CabalStaticLibExperiment.obj : error LNK2019: unresolved external symbol _hs_exit referenced in function _main
1>libHSHaskellCabalLib-0.1.0.0.lib(Main.o) : error LNK2001: unresolved external symbol _base_GHCziIOziHandleziText_hGetContents1_closure
1>libHSHaskellCabalLib-0.1.0.0.lib(Main.o) : error LNK2001: unresolved external symbol _stg_upd_frame_info
...
1>libHSHaskellCabalLib-0.1.0.0.lib(Data.o) : error LNK2001: unresolved external symbol _ghczmprim_GHCziCString_unpackCStringzh_info
1>CabalStaticLibExperiment.exe : fatal error LNK1120: 56 unresolved externals
I've next question: how can I connect Haskell FFI static library with MS Visual Studio project? How can I resolve this dependencies?