Bytestring linking in ghc
Asked Answered
B

1

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?

Brainard answered 6/11, 2012 at 19:46 Comment(5)
Which version of bytestring was cryptohash built against?Fourthclass
@DanielFischer Hackage says, cryptohash 0.7.6 was built using ghc 7.6 (I use 7.4). Could it be a problem?Brainard
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.Fourthclass
@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?Brainard
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.Fourthclass
R
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.

Rambler answered 15/11, 2012 at 13:25 Comment(1)
Here's your other response to similar question.Makebelieve

© 2022 - 2024 — McMap. All rights reserved.