1
votes

I've installed the Haskell Compiler and glpk-hs using the instructions here. Further, I've used cabal install glpk-hs to install required files in an attempt to compile a Haskell Program.

However, the cabal installation of glpk is not working. The following message keeps popping up:

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

As above, I have tried both installing glpk in a nonstandard location and the standard location, but in all cases, has been unable to find the glpk.

The glpsol solver, which uses GLPK is installed though, as it shows the version of which it is currently running: GLPSOL: GLPK LP/MIP Solver, v4.62

1
C dependencies are typically detected via pkg-config. Does pkg-config know about glpk? What does pkg-config --modversion glpk say? You might consider searching for an appropriate *.pc file on your hard drive -- e.g. look through the output of locate '*.pc' for something that looks glpk-related -- and make sure the directory that file is in is on your PKG_CONFIG_PATH. - Daniel Wagner
@DanielWagner I tried the pkg-config --modversion glpk, and it said that the command was not found. I also attempted the locate '*.pc', and looked for something related to glpsol or glpk, and there was nothing. Do you think it's a problem with pkg-config? - Fandom_Lover
Perhaps not. I just checked the cabal file for glpk-hs, and it uses extra-libraries, not pkgconfig-depends. So my previous comments about pkg-config are probably a red herring. (Sorry.) - Daniel Wagner
Followup question: can ld find your glpk library? (Can you build a C program that uses glpk?) - Daniel Wagner
No worries. Hm, I'm having trouble testing the ld finding the glpk, as I'm not too familiar with C. Though going by the glpsol (command line solver), command line recognizes the GLPK package. - Fandom_Lover

1 Answers

1
votes

Figured it out! hmatrix-glpk had the extra directories for OS X in the .cabal file:

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

Copying this into the glpk-hs.cabal allows the installation to work.