Cabal rebuild all with enable-shared flag
Asked Answered
D

1

7

I am having an issue with building a shared library with ghc and I think I need to rebuild my haskell packages with --enable-shared, is there an easy way to rebuild all of my packages with cabal with the flag --enable-shared?

Doorstep answered 2/11, 2011 at 13:42 Comment(0)
C
7

If you have a ~/.cabal/world, cabal install --reinstall --enable-shared world could work, but test with the --dry-run flag first. That will, however only take care of cabal-installed packages. If you have packages installed with your distro's package manager, the distro might also provide shared versions for those (otherwise, you'd have to do it manually). Also, it would probably be helpful to set shared: True in ~/.cabal/config.

Crinkleroot answered 2/11, 2011 at 13:58 Comment(7)
Thanks for the quick reply! It seems like world is leaving out base, is that cabals responsibility or ghc?Doorstep
and I'm getting: "XMonad.hs:47:8: Could not find module Control.Monad.Reader': Perhaps you haven't installed the "dyn" libraries for package mtl-2.0.1.0'? Use -v to see a list of the files searched for."Doorstep
You cannot reinstall base. And reinstalling other boot packages will cause massive breakage too. Do not even attempt that. However, shared libraries for the boot packages should be available, afair, they're included in the binaries from ghc's download page and built automatically if you build from source. If you got your ghc from a distro package, the distro should provide shared packages too (for the boot libs at least).Crinkleroot
Then I'm not sure why I am getting "ghc -shared -o libTest.so -optc-O test_JniTest.c Safe_stub.o -I/usr/lib/jvm/java-6-sun-1.6.0.26/include -I/usr/lib/jvm/java-6-sun-1.6.0.26/include/linux /usr/bin/ld: /usr/local/lib/ghc-7.0.3/base-4.3.1.0/libHSbase-4.3.1.0.a(TopHandler__12.o): relocation R_X86_64_32 against `base_GHCziTopHandler_zdLr2haa_closure' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/ghc-7.0.3/base-4.3.1.0/libHSbase-4.3.1.0.a: could not read symbols: Bad value" Should these already be shared libraries?Doorstep
Try recompiling with -fPIC in addition to -shared.Crinkleroot
Same error when I add -fPIC, I suspect that the error is implying that I need to recompile base with -fPIC, but I don't knowDoorstep
Does locate libHSbase-4.3.1.0-ghc7.0.3.so find anything? Probably not, or it should work. So then you don't have the shared boot libraries. Where did you get your ghc from? Distro, probably. If your distro also provides a package with shared libs, install that. If not, you'll probably have to install a complete new GHC with shared libs. If not distro, how?Crinkleroot

© 2022 - 2024 — McMap. All rights reserved.