字节串连接在ghc中

Car*_*s00 7 haskell ghc static-linking bytestring

请考虑以下简单代码:

import Crypto.Hash.SHA1 (hashlazy)
import qualified Data.ByteString as BS
main = return ()
Run Code Online (Sandbox Code Playgroud)

我安装cabal install --global bytestring然后获得(在使用ghc 7.4.1的新安装的Ubuntu 12.04机器上):

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.
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

Don*_*art 6

这是钻石依赖问题.你有一个版本的cryptohash针对一个版本的bytestring构建,但GHC系统的其余部分是针对另一个版本构建的.因此,当包被链接在一起时,会链接两个稍微不同的bytestring版本.

通常这是可以的,只要bytestring类型是兼容的.

但是,bytestring包含一些用于某些实用程序的小型库.C库具有非唯一符号,可防止重复链接,从而防止出错.

您需要确保cryptohash是针对相同版本的bytestring构建的.