6

The basic problem:

I'm attempting to install Haskell's gtk package using the standard mac instructions on OSX 10.10.4. Specifically, I want to run threadscope, so I need gtk. Early stages with homebrew and the gtk buildtools work fine, but when I

cabal install gtk

or use

cabal install --with-gcc=gcc-4.8 gtk

I get the following compilation error:

Graphics/UI/Gtk/Embedding/Plug.chs:120:6:
Couldn't match expected type ‘Ptr ()’
            with actual type ‘Maybe DrawWindow’
In the first argument of ‘gtk_plug_new’, namely
  ‘(fromNativeWindowId (fromMaybe nativeWindowIdNone socketId))’
In the second argument of ‘($)’, namely
  ‘gtk_plug_new
     (fromNativeWindowId (fromMaybe nativeWindowIdNone socketId))’

Graphics/UI/Gtk/Embedding/Plug.chs:137:6:
Couldn't match expected type ‘Ptr ()’
            with actual type ‘Maybe DrawWindow’
In the second argument of ‘\ (Display arg1) arg2
                             -> withForeignPtr arg1
                                $ \ argPtr1 -> gtk_plug_new_for_display argPtr1 arg2’, namely
  ‘(fromNativeWindowId (fromMaybe nativeWindowIdNone socketId))’
In the second argument of ‘($)’, namely
  ‘(\ (Display arg1) arg2
      -> withForeignPtr arg1
         $ \ argPtr1 -> gtk_plug_new_for_display argPtr1 arg2)
     display
     (fromNativeWindowId (fromMaybe nativeWindowIdNone socketId))’

Graphics/UI/Gtk/Embedding/Plug.chs:151:3:
Couldn't match type ‘Ptr ()’ with ‘Maybe DrawWindow’
Expected type: IO (Maybe DrawWindow)
  Actual type: IO (Ptr ())
In the second argument of ‘($)’, namely
  ‘(\ (Plug arg1)
      -> withForeignPtr arg1 $ \ argPtr1 -> gtk_plug_get_id argPtr1)
     (toPlug self)’
In the expression:
  liftM toNativeWindowId
  $ (\ (Plug arg1)
       -> withForeignPtr arg1 $ \ argPtr1 -> gtk_plug_get_id argPtr1)
      (toPlug self)
cabal: Error: some packages failed to install:

I previously had Haskell's gtk library and threadscope application installed and running before I updated my Haskell platform from ghc 7.8.4 to ghc 7.10.2. At first I assumed an installation conflict, but I've repeatedly removed the Haskell platform from my system using the thorough removal instructions and reattempted the threadscope installation with no success. I've even removed and re-installed the underlying gtk+ and related packages using homebrew, again no success.

I'm not sure where the types Ptr () and Maybe DrawWindow originate and therefore where the conflict could be coming from. Any ideas on what could be going wrong would be welcome!

recursion.ninja
  • 5,377
  • 7
  • 46
  • 78

2 Answers2

3

maybe you could try to install gtk with this line

cabal install gtk -fhave-quartz-gtk

Max K
  • 171
  • 12
1

There is a recipe for installing GTK and threadscope at edsko's blog:

http://www.edsko.net/2015/03/09/sandboxes-revisited/

Search the page for "GTK sandbox".

Update

I was able to build threadscope using the above instructions with ghc-7.10.2.

The specific commands I used:

export PATH=/opt/X11/lib/pkgconfig
brew install gtk+                      # installed gtk+-2.24.25
brew install poppler                   # installed poppler-0.35.0
cabal sandbox init
cabal install gtk2hs-buildtools
cabal install gtk
cabal install poppler --with-gcc=gcc-4.9 --extra-include-dirs=/usr/local/include
cabal install threadscope

The specific versions of packages installed in the sandbox:

cairo-0.13.1.0
ghc-events-0.4.4.0
gio-0.13.1.0
glib-0.13.2.1
gtk-0.13.9
hashtables-1.2.0.2
pango-0.13.1.0
poppler-0.13.1
utf8-string-1.0.1.1
ErikR
  • 51,541
  • 9
  • 73
  • 124
  • Hi, thank you for your response! Sadly this resulted in the same errors as above during the build of gtk. – G. A. Newman Oct 21 '15 at 19:02
  • Are you using GHC 7.10.2? The above recipe builds threadscope in a sandbox, so you can follow it without disturbing your installed packages if you are currently on a different version of GHC. – ErikR Oct 21 '15 at 19:26
  • Yes, I'm using GHC 7.10.2, and I'm very confused why the recipe didn't work, since a sandbox was my sure thing of last resort. – G. A. Newman Oct 22 '15 at 20:21
  • Some ideas: perform a `cabal update`; use a cabal.config to lock down the versions of the above packages. – ErikR Oct 22 '15 at 21:56
  • The key for me was to do cabal install gtk -fhave-quartz-gtk as suggested above – George Co Nov 26 '16 at 00:30