7

Consider the following simple code:

import Crypto.Hash.SHA1 (hashlazy)
import qualified Data.ByteString as BS
main = return ()

I installed cabal install --global bytestring and then I obtain (on a newly installed Ubuntu 12.04 machine using ghc 7.4.1):

GHCi runtime linker: fatal error: I found a duplicate definition for symbol
   fps_minimum
whilst processing object file
   /usr/local/lib/bytestring-0.10.0.1/ghc-7.4.1/HSbytestring-0.10.0.1.o
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
     loaded twice.
GHCi cannot safely continue in this situation.  Exiting now.  Sorry.

What can I do with that?

Don Stewart
  • 137,316
  • 36
  • 365
  • 468
Cartesius00
  • 23,584
  • 43
  • 124
  • 195
  • 1
    Which version of `bytestring` was `cryptohash` built against? – Daniel Fischer Nov 06 '12 at 19:56
  • @DanielFischer Hackage says, `cryptohash 0.7.6` was built using `ghc 7.6` (I use `7.4`). Could it be a problem? – Cartesius00 Nov 06 '12 at 20:03
  • 1
    No, I meant the one you have. `ghc-pkg describe cryptohash` will list something like `bytestring-0.10.0.0-b8146809d010d5e46cdb979e5b99953f` in the depends field. If that is not the same version of `bytestring` that the `import qualified Data.ByteString as BS` pulls in, you have your duplicate symbol error. – Daniel Fischer Nov 06 '12 at 20:08
  • 1
    @DanielFischer Oh, thanks! Describe prints: `bytestring-0.9.2.1-18f26186028d7c0e92e78edc9071d376` but I have installed `bytestring-0.10.0.1`, so that's the problem, right? – Cartesius00 Nov 06 '12 at 20:22
  • 2
    Right, you have to rebuild cryptohash against the new `bytestring`, or tell ghc(i) to use the old whenever you use cryptohash. - Note, you may need to rebuild other packages too. – Daniel Fischer Nov 06 '12 at 20:24

1 Answers1

6

This is a diamond dependency issue. You have a version of cryptohash built against one version of bytestring, but the rest of the GHC system built against another. Thus when the packages are linked together, two slightly different versions of bytestring are linked.

Normally this is ok, as long as the bytestring types are compatible.

However, bytestring includes a small C library for some utilities. C libraries have non-unique symbols, that prevent duplicate linking, hence your error.

You need to ensure cryptohash is built against the same version of bytestring.

Don Stewart
  • 137,316
  • 36
  • 365
  • 468