Reputation: 21811
I have a C++ library bundled with (and called from) a Haskell library. I'm using a custom build with a cabal
, Makefile
, and Setup.hs
files almost identical to those described here. I also want to use GHCi, so my Makefile
creates a dynamic (.so
) library in addition to the static (.a
) library.
Note: I think GHCi must use dynamic libraries; if I'm wrong about this then maybe there is an easier solution.
I can make GHCi work in this environment by passing an explicit path to the .so file. This post is about how to make stack ghci
work. The main error this produces is cannot find libfoo.so
(due to adding extra-libraries: foo
in the cabal file). Using -v reveals that stack is not looking in the "extra-lib-dirs" paths that I modified in the Setup.hs script (possible bug bug). stack ghci
does look for libraries in the "extra-lib-dirs" that are specified in the cabal file. Unfortunately, due to a cabal bug, I cannot specify a relative path for extra-lib-dirs: it causes both cabal configure
and stack build
to fail with the same error.
I don't want to install my C++ library system-wide (which would resolve the issue by allowing me to use an absolute path in extra-lib-dirs).
Concrete questions:
.so
file to use GHCi?stack ghci
where to look for a library in a relative path?Upvotes: 3
Views: 540
Reputation: 21811
This answer shows a cleaner way to include a C++ library with a Haskell library that does not require the use of extra-libraries
or relative paths. The idea is to let cabal do all the heavy lifting instead of using a custom build-type.
stack ghci
works (with some caveats on build order due to a GHC bug).
Upvotes: 0