首页 > 解决方案 > 安装带有 C 依赖项的 Haskell 包时出现问题 (glpk)

问题描述

Haskell 包Numeric.LinearProgramming依赖于 C 库glpk。尝试使用命令在 Ubuntu 18.04 上安装时cabal install hmatrix-glpk-0.19.0.0出现以下错误:

Resolving dependencies...
Notice: installing into a sandbox located at /home/owen/.cabal-sandbox
Configuring hmatrix-glpk-0.19.0.0...
Failed to install hmatrix-glpk-0.19.0.0
Build log ( /home/owen/.cabal-sandbox/logs/hmatrix-glpk-0.19.0.0.log ):
cabal: Entering directory '/tmp/cabal-tmp-7470/hmatrix-glpk-0.19.0.0'
Configuring hmatrix-glpk-0.19.0.0...
cabal: Missing dependency on a foreign library:
*Missing C library: glpk
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.
cabal: Leaving directory '/tmp/cabal-tmp-7470/hmatrix-glpk-0.19.0.0'
cabal: Error: some packages failed to install:
hmatrix-glpk-0.19.0.0 failed during the configure step. The exception was:
ExitFailure 1

我已经glpk-utils安装在标准位置(通过 APT)/usr/share/doc/glpk-utils/,但按照建议,我尝试添加--extra.../path to glpk-utils标签,但失败并显示相同的消息。

这里可能是什么问题?安装包是否glpk-utils正确?卡巴尔看不到吗?还有什么?

标签: haskellubuntu-18.04cabalglpk

解决方案


您需要安装libglpk-dev软件包。

libglpk(需要的glpk-utils)和之间的区别,例如libglpk-dev,请参考https://askubuntu.com/questions/1008912/whats-the-difference-between-dev-package-and-ordinary-package。通常,Haskell FFI 需要-dev错误消息中所述的软件包。


推荐阅读