Cabal报告 "/usr/bin/ld: cannot find -lHSrandom-1.0.1.1-ghc7.8.3"。

8
我有一台Ubuntu 14.04LTS的电脑。我从http://www.haskell.org/ghc/download_ghc_7_8_3#x86_64linux下载了最新版本的ghc-7.8.3并将其安装到/usr/local目录下。然后,我升级了我的cabal到版本1.20.0.3。接着,在终端中输入cabal install QuickCheck,结果显示:
Resolving dependencies...
Configuring tf-random-0.5...
Building tf-random-0.5...
Preprocessing library tf-random-0.5...
[1 of 4] Compiling System.Random.TF.Gen ( src/System/Random/TF/Gen.hs, dist/build/System/Random/TF/Gen.o )
[2 of 4] Compiling System.Random.TF.Init ( src/System/Random/TF/Init.hs, dist/build/System/Random/TF/Init.o )

src/System/Random/TF/Init.hs:94:5: Warning:
    In the use of ‘bitSize’ (imported from Data.Bits):
    Deprecated: "Use 'bitSizeMaybe' or 'finiteBitSize' instead"
[3 of 4] Compiling System.Random.TF.Instances ( src/System/Random/TF/Instances.hs, dist/build/System/Random/TF/Instances.o )
[4 of 4] Compiling System.Random.TF ( src/System/Random/TF.hs, dist/build/System/Random/TF.o )
/usr/bin/ld: cannot find -lHSrandom-1.0.1.1-ghc7.8.3
collect2: error: ld returned 1 exit status
Failed to install tf-random-0.5
cabal: Error: some packages failed to install:
QuickCheck-2.7.5 depends on tf-random-0.5 which failed to install.
tf-random-0.5 failed during the building phase. The exception was:
ExitFailure 1

顺便提一下,我之前已经通过 apt-get 安装了 haskell-platformghc-7.6.3.

1个回答

12

我记得在安装ghc-7.8时遇到过类似的问题。它与新版cabal有关,一些使用旧版本安装的库与其不兼容(但它无法提供正确的问题原因)。

无论如何,我认为重新安装相关的软件包会有所帮助。

cabal install random --reinstall --force-reinstalls 

设置好之后,cabal install tf-random 应该会成功安装。


像往常一样,使用Cabal时,最简单的解决方案是最好的选择。 - user1971598
3
这也可以修复其他库的类似错误。如果您看到“/usr/bin/ld: cannot find -lHSfoobar-1.0.1.1-ghc7.8.3”,那么您需要运行cabal install foobar -reinstall --force-reinstalls命令。您可能需要指定特定的版本。 - Buttons840
我在使用gmp库时遇到了类似的错误,请参考我的问题,但不幸的是上述解决方法并没有起作用。还有其他建议吗? - The Dude

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接