Cabal 安装链接错误
Cabal install linking error
我对 Haskell 编程还很陌生,在使用 Cabal 创建我的第一个正确项目的过程中我遇到了错误。
我在构建项目时遵循了 this 教程。但是,当我到达必须输入 cabal install -j
的步骤时,出现以下错误:
cabal: Entering directory '.'
Configuring CabalTest-0.1.0.0...
Building CabalTest-0.1.0.0...
Preprocessing executable 'CabalTest' for CabalTest-0.1.0.0...
Linking dist/dist-sandbox-fe048ba8/build/CabalTest/CabalTest ...
/usr/bin/ld: cannot find -lHSbase-4.9.1.0
/usr/bin/ld: cannot find -lHSinteger-gmp-1.0.0.1
/usr/bin/ld: cannot find -lHSghc-prim-0.5.0.0
/usr/bin/ld: cannot find -lHSrts
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
cabal: Leaving directory '.'
我试过 运行 cabal install base integer-gmp ghc-prim rts --reinstall
,它回答说找不到 rts。当我修改命令以排除 rts 时,它输出的是:
cabal: Could not resolve dependencies:
next goal: base (user goal)
rejecting: base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0,
base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0,
base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1,
base-4.2.0.0, base-4.1.0.0, base-4.0.0.0 (only already installed instances can
be used)
rejecting: base-3.0.3.2 (conflict: base => base>=4.0 && <4.3)
rejecting: base-3.0.3.1 (conflict: base => base>=4.0 && <4.2)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
运行 cabal update
没有帮助,更改 ~/.cabal/config 文件以包含 user-install: False
也没有做任何事情。
我解决了这个问题。事实证明问题是由于我通过 pacman 获得的 GHC 包(我正在使用 arch linux)。这里的问题是,每当 GHC 尝试 link 到任何库时,它都会静态地这样做。但是,GHC 的 pacman 包不包含任何所需的静态库。为了解决这个问题,我必须安装一个名为 ghc-static 的单独包,其中包含所有静态库。
我对 Haskell 编程还很陌生,在使用 Cabal 创建我的第一个正确项目的过程中我遇到了错误。
我在构建项目时遵循了 this 教程。但是,当我到达必须输入 cabal install -j
的步骤时,出现以下错误:
cabal: Entering directory '.'
Configuring CabalTest-0.1.0.0...
Building CabalTest-0.1.0.0...
Preprocessing executable 'CabalTest' for CabalTest-0.1.0.0...
Linking dist/dist-sandbox-fe048ba8/build/CabalTest/CabalTest ...
/usr/bin/ld: cannot find -lHSbase-4.9.1.0
/usr/bin/ld: cannot find -lHSinteger-gmp-1.0.0.1
/usr/bin/ld: cannot find -lHSghc-prim-0.5.0.0
/usr/bin/ld: cannot find -lHSrts
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
cabal: Leaving directory '.'
我试过 运行 cabal install base integer-gmp ghc-prim rts --reinstall
,它回答说找不到 rts。当我修改命令以排除 rts 时,它输出的是:
cabal: Could not resolve dependencies:
next goal: base (user goal)
rejecting: base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0,
base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0,
base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1,
base-4.2.0.0, base-4.1.0.0, base-4.0.0.0 (only already installed instances can
be used)
rejecting: base-3.0.3.2 (conflict: base => base>=4.0 && <4.3)
rejecting: base-3.0.3.1 (conflict: base => base>=4.0 && <4.2)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
运行 cabal update
没有帮助,更改 ~/.cabal/config 文件以包含 user-install: False
也没有做任何事情。
我解决了这个问题。事实证明问题是由于我通过 pacman 获得的 GHC 包(我正在使用 arch linux)。这里的问题是,每当 GHC 尝试 link 到任何库时,它都会静态地这样做。但是,GHC 的 pacman 包不包含任何所需的静态库。为了解决这个问题,我必须安装一个名为 ghc-static 的单独包,其中包含所有静态库。