[Haskell-cafe] Cabal depend on local package with foreign dependencies

Richard Lewis richard.lewis at gold.ac.uk
Tue Oct 27 15:08:26 UTC 2015

Hi there,

I have two libraries that I'm working on, packageA and packageB.

packageA was written some time ago and depends on a foreign C library,
libfoo, which I also wrote and which is installed in a non-standard
location. packageB depends on packageA and is new and under active

I have the following things, then:

 - libfoo is installed in ~/.local/lib, with includes in ~/.local/include/foo
 - packageA is in ~/src/packageA
 - packageB is in ~/src/packageB

packageA has a .cabal file which includes:

  build-depends: base, ...
  exposed-modules: A
  include-dirs: /home/richard/.local/include
  extra-lib-dirs: /home/richard/.local/lib

executable testA
  extra-lib-dirs: /home/richard/.local/lib
  extra-libraries: foo

I've created a cabal sandbox in packageA and I can successfully build

Now, packageB makes use of packageA. It has a .cabal file which looks
like this:

  build-depends: base, packageA, ...
  exposed-modules: B

executable testB
  extra-lib-dirs: /home/richard/.local/lib
  extra-libraries: foo

Again, I've created a cabal sandbox in packageB. In order to be able
to use packageA (which is not installed anywhere) I believe I have to

$ cabal add-source ~/src/packageA

Next, when I try and configure, it says:

cabal: At least the following dependencies are missing:
packageA -any

That's fine, I assume, because I can now just `cabal install
--only-dependencies` to get packageA built into packageB's
sandbox. But when I try and do this, I get:

$ cabal install --only-dependencies
Resolving dependencies...
Configuring packageA-0.1...
Building packageA-0.1...
Preprocessing library packageA-0.1...
In-place registering packageA-0.1...
Preprocessing executable 'testA' for packageA-0.1...
Foo.hsc:10:33: fatal error: foo/foo.h: No such file or directory
compilation terminated.

So a target of packageA which compiles fine when doing cabal build
directly from packageA now fails to compile when I attempt to build it
from packageB by installing packageB's dependencies.

I'm not sure how to proceed. It feels like maybe I have to tell
cabal--when running it from packageB--where the include files are for
packageA, because packageA needs to get compiled (which involves
linking against libfoo and using libfoo's includes). I know that
packageA *does* compile (because I've done that already), but it won't
compile inside packageB's sandbox.

Any suggestions?


More information about the Haskell-Cafe mailing list