1

I'm struggling to install GTK / gtk2hs binding on Linux Mint 17.

The first time I encountered this problem was when I tried to get glade support in Haskell.

There were the same problems but it was purely for fun so I let it be.

This time I was trying to visualize a graph with Haskell Chart.

The problem occured in the forth step cabal install chart-cairo

I'm using GHC version 7.6.3, cabal version 1.16.0.2, gtk2hs-buildtools version 0.12.4-2ubuntu1 (from the package manager), gtk2hsC2hs version 0.13.6 (this is where glade needs to have >=0.13.8, but I can't find a newer version)

Things I've tried so far:

  1. After downloading the gtk2hs-buildtools from the package manager I updated cabal and installed the tools from the command line

  2. Added the "$HOME/.cabal/bin" to the front of $PATH (after that gtk installed correctly)

  3. cabal install chart-cairo gets me this error message

    Resolving dependencies...    
    [1 of 2] Compiling SetupWrapper     ( /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/SetupWrapper.hs, /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/dist/setup/SetupWrapper.o )    
    [2 of 2] Compiling Main             ( /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/dist/setup/setup.hs, /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/dist/setup/Main.o )    
    Linking /tmp/cairo-0.13.0.2-19862/cairo-0.13.0.2/dist/setup/setup ...    
    [1 of 2] Compiling Gtk2HsSetup      ( Gtk2HsSetup.hs, dist/setup-wrapper/Gtk2HsSetup.o )    
    [2 of 2] Compiling Main             ( SetupMain.hs, dist/setup-wrapper/Main.o )    
    Linking dist/setup-wrapper/setup ...    
    Configuring cairo-0.13.0.2...    
    Building cairo-0.13.0.2...    
    Preprocessing library cairo-0.13.0.2...    
    [ 1 of 18] Compiling Graphics.Rendering.Cairo.Matrix ( dist/build/Graphics/Rendering/Cairo/Matrix.hs, dist/build/Graphics/Rendering/Cairo/Matrix.o )    
    [ 2 of 18] Compiling Graphics.Rendering.Cairo.Types ( dist/build/Graphics/Rendering/Cairo/Types.hs, dist/build/Graphics/Rendering/Cairo/Types.o )    
    [ 3 of 18] Compiling Graphics.Rendering.Cairo.Internal.Utilities ( dist/build/Graphics/Rendering/Cairo/Internal/Utilities.hs, dist/build/Graphics/Rendering/Cairo/Internal/Utilities.o )    
    
    Graphics/Rendering/Cairo/Internal/Utilities.chs:24:42:    
        Module `Data.Text.Foreign' does not export `withCStringLen'    
    Failed to install cairo-0.13.0.2    
    cabal: Error: some packages failed to install:    
        Chart-cairo-1.3.2 depends on cairo-0.13.0.2 which failed to install.    
        cairo-0.13.0.2 failed during the building phase. The exception was:    
        ExitFailure 1    
    
  4. pkg-config cairo --modversion tells me I have the version 1.13.1 (which is newer than 0.13.0.2?)

Mihai Maruseac
  • 20,967
  • 7
  • 57
  • 109
Cirquit
  • 464
  • 2
  • 9

3 Answers3

1

I just tried it myself, and hit some snags that I was able to overcome.... Perhaps you are having the same problem.

For some reason, some dependencies would not automatically install. It is easy to install them by hand though. Try this:

cabal install alex
cabal install gtk2hs-buildtools
cabal install cairo
cabal install chart-cairo

In general, if you see an error message in your cabal output like the following line in your post

Failed to install cairo-0.13.0.2   

it is a good idea to try the install manually. Although dependencies are supposed to be worked out, I've run into many cases where they don't (I think it might have to do with cabal installing command line tools, but have never looked into it fully). In this particular case, that is what I did, but I had to go up the chain 4 times....

jamshidh
  • 12,002
  • 17
  • 31
  • I tried to install everything from scratch, but unfortunately it didn't help. Could you please tell me how to install the missing packages manually? My google fu didn't help me at all. Btw the problem with the "old" gtk2hsC2hs version was fixed by installing gtk2hs-buildtools with root and now there is a new error message `Module Data.Text.Foreign' does not export 'withCStringLen' Failed to install cairo-0.13.0.2`. – Cirquit Dec 02 '14 at 21:45
  • In this case, what I did was the lines above.... What happened when you tried this? – jamshidh Dec 02 '14 at 22:10
  • I did the lines in your order and there was said error with `Module Data.Test.Foreign...Failed to install cairo-0.13.0.2`. After installing glade (hence the gtk2hs-buildtools are "working") it somehow installed chart-cairo **successfully**. The glade install took fairly long and I think I've seen it download something gtk-esque. But I still can't comprehend why and how this all has to do something with as simple as running cabal as root. – Cirquit Dec 02 '14 at 22:34
  • Well, I tried the exact same steps on my laptop and it won't install again. It has the same settings as in the first post, except a newer cabal version `1.20.0.3`. `sudo cabal install alex` and `sudo cabal install gtk2hs-buildtools` installed without problems. Both `sudo cabal install cairo` and `sudo cabal install chart-cairo` got me the error message `The pkg-config package 'cairo' version >=1.2.0 is required but it could not be found. Failed to install cairo-0.13.0.5`. If I try to install gtk or glade they both can't find gio/glib/cairo packages. – Cirquit Dec 03 '14 at 00:56
  • I know it is pretty generic info, but have you tried `cabal update`. Also, `cabal unpack cairo`, then cd'ing into the dir, then `cabal configure`, `cabal build` sometime helps understand the problem. – jamshidh Dec 03 '14 at 01:04
  • Thank you very much for your time you took to help me! The commands you posted certainly helped to get a better grasp on the problem. Unfortunately the only thing that worked was to find the the libghc-cairodev package through the Software Manager. So charts are working right now, but gtk still misses the other packages (I couldn't find pango in the list) and I have to find another way. – Cirquit Dec 03 '14 at 01:30
0
  1. An old version of text is being used (also causing cabal to choose the old version of cairo with bad build-deps). Try adding --constraint='cairo>=0.13.0.5' to your cabal install. That should also force cabal to choose a newer version of text.

  2. pkg-config cairo --modversion gives the version of the actual cairo library. 0.13.0.2 is the version of the Gtk2Hs haskell package that wraps cairo (actual cairo version wrapped depends what is installed)

0

I encountered the same issue. This is a late reply but a good resource for this problem is found here. On my Debian system (Linux Mint) I found that doing:

sudo apt-get install libghc-gtk-dev

solved the problem. But the link provides installation advice for several Linux based systems as well as Windows, BSD and Mac.

AsymLabs
  • 933
  • 9
  • 15