开发者

ghc can't find my cabal installed packages

I've installed ghc 6.12.3, and then the Haskell Platform. I'm trying to compile a test program:

$ ghc test.hs
test.hs:3:0:
    Failed to load interface for `Bindings':
      Use -v to see a list of the files searched for.

so, naturally, I do

cabal install Bindings

Which works fine, and places the package in ~/.cabal/lib/bindings-0.1.2 The problem is, that when I go to compile again with ghc, it still doesn't find the package I've installed with cabal. compiling in verb开发者_如何学运维ose mode gives:

ghc -v test.hs
Using binary package database: /home/ludflu/ghc/lib/ghc-6.12.3/package.conf.d/package.cache
Using binary package database: /home/ludflu/.ghc/x86_64-linux 6.12.3/package.conf.d/package.cache

As suggested by another stackoverflow user, I tried:

ghc-pkg describe rts > rts.pkg
vi rts.pkg                      # add the /home/ludflu/.cabal/lib to `library-dirs` field
ghc-pkg update rts.pkg

But to no avail. How to I add the .cabal to the list of package directories to search? Thank you!


You can check which packages are installed with ghc-pkg list. It may be that you need to either specify the packages to ghc with -package <pkgname> or I believe adding --make to will trigger a chasing down of dependencies, including packages.

Edit: the bindings package is obsolete indeed, see the hackage page. This isn't a package management problem, the only module available is Bindings.Deprecated, which you are perfectly able to load, even though it is an empty module. I believe the relevant parts have been broken out into bindings-<module>, so if you want the bindings functionality you should look to those packages.


http://www.haskell.org/haskellwiki/Cabal-install

One thing to be especially aware of, is that the packages are installed locally by default by cabal, whereas the commands

runhaskell Setup configure
runhaskell Setup build
runhaskell Setup install

install globally by default. If you install a package globally, the local packages are ignored. The default for cabal-install can be modified by editing the configuration file.

I was getting the same error with the runhaskell command. I used the cabal in the directory that had the .cabal file and was able to resolve the error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜