Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bytestring linking in ghc

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?

like image 456
Cartesius00 Avatar asked Nov 06 '12 19:11

Cartesius00


1 Answers

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.

like image 145
Don Stewart Avatar answered Nov 10 '22 09:11

Don Stewart