字节串连接在ghc中

时间:2012-11-06 19:46:35

标签: haskell ghc static-linking bytestring

考虑以下简单代码:

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

我安装了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.

我该怎么办?

1 个答案:

答案 0 :(得分:6)

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

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

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

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