无法安装 glpk-hs

Unable to Install glpk-hs

我已经使用说明 here 安装了 Haskell 编译器和 glpk-hs。此外,我使用 cabal install glpk-hs 来安装所需的文件以尝试编译 Haskell 程序。

但是,glpk 的 cabal 安装不工作。不断弹出以下消息:

Resolving dependencies...

Configuring glpk-hs-0.5...

Failed to install glpk-hs-0.5

Build log :

cabal: Entering directory '/var/folders/cr/9f1ltj7d4b31hmkfn03hjl_r0000gn/T/cabal-tmp-12521/glpk-hs-0.5'

Configuring glpk-hs-0.5...

cabal.real: 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 '/var/folders/cr/9f1ltj7d4b31hmkfn03hjl_r0000gn/T/cabal-tmp-12521/glpk-hs-0.5'

cabal: Error: some packages failed to install: glpk-hs-0.5 failed during the configure step. The exception was:

ExitFailure 1

如上所述,我已经尝试在非标准位置和标准位置安装 glpk,但在所有情况下,都无法找到 glpk。

尽管安装了使用 GLPK 的 glpsol solver,因为它显示了当前 运行 的版本:GLPSOL: GLPK LP/MIP Solver, v4.62

想通了! hmatrix-glpk 在 .cabal 文件中有 OS X 的额外目录:

if os(OSX)
     extra-lib-dirs: /usr/lib
     extra-lib-dirs: /opt/local/lib/
     include-dirs: /opt/local/include/
     extra-lib-dirs: /usr/local/lib/
     include-dirs: /usr/local/include/
     if arch(i386)
         cc-options: -arch i386

将其复制到 glpk-hs.cabal 允许安装工作。