【问题标题】:Cabal install (Cabal cabal-install) fails due to missing zlib library由于缺少 zlib 库,Cabal 安装 (Cabal cabal-install) 失败
【发布时间】:2021-03-13 16:29:23
【问题描述】:

我想在 Ubuntu 20.04 上安装 Cabal 3.4.0.0。

$ sudo apt install cabal-install
$ cabal --version
cabal-install version 2.4.0.0

$ sudo cabal update
$ sudo cabal install Cabal cabal-install
...
Starting     zlib-0.6.2.3
Failed to install zlib-0.6.2.3
Build log ( /root/.cabal/logs/ghc-8.6.5/zlib-0.6.2.3-93Wbo8gIIzI9bg4p2MsNUF.log ):
cabal: Entering directory '/tmp/cabal-tmp-126381/zlib-0.6.2.3'
Configuring zlib-0.6.2.3...
cabal: Missing dependency on a foreign library:
* Missing (or bad) header file: zlib.h
* Missing (or bad) C library: z
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
...
cabal: Error: some packages failed to install:
cabal-install-3.4.0.0-3glzV3hM64DLoOfz3dHKsn depends on cabal-install-3.4.0.0
which failed to install.
hackage-security-0.6.0.1-KiAyVYLxooJAP3ckeQHnBD depends on
hackage-security-0.6.0.1 which failed to install.
zlib-0.6.2.3-93Wbo8gIIzI9bg4p2MsNUF failed during the configure step. The
exception was:
ExitFailure 1

错误提示:

这个问题通常可以通过安装系统包来解决 提供这个库(你可能需要“-dev”版本)。

如何在 Ubuntu 20.04 上安装此软件包?

【问题讨论】:

  • sudo apt-get install zlib1g-dev
  • @WillemVanOnsem 谢谢,这行得通!您是如何找到这些信息的(这样我下次可以自己找到)?
  • 命令apt-cache 很有用。尝试“apt-cache search zlib”。见related SE question
  • @WillemVanOnsem 你应该发表你的评论作为答案,这样它才能被接受。

标签: haskell cabal cabal-install


【解决方案1】:

您的目标是安装cabal-install package。这个包有一个依赖,这里会产生一个问题:zlib package

这个zlib 包本质上是一个围绕zlib C library [wikipedia] 的薄包装。然而,正如错误所说,您没有安装 zlib 库,或者至少没有安装可以使用 zlib 库进行开发的软件包。

我们可以通过安装libghc-zlib-dev software package 来安装它,例如:

sudo apt-get install <strong>libghc-zlib-dev</strong>

如果我们检查package details on Debian,我们会看到本质上这是一个将安装zlib1g-dev 软件包的软件包,该软件包用于使用zlib 库开发软件。因此我们可以决定安装libghc-zlib-dev,或者zlib1g-dev

sudo apt-get install <strong>zlib1g-dev</strong>

【讨论】:

  • sudo apt-get install zlib1g-dev 没有效果,但sudo apt-get install libghc-zlib-dev 做到了,谢谢。
猜你喜欢
  • 2016-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-03
  • 2015-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多