Cabal安装gtk失败

时间:2015-08-13 22:04:21

标签: haskell gtk cabal c2hs

我试图通过cabal安装gtk,但是,我在构建时遇到以下类型错误

[ 22 of 209] Compiling Graphics.UI.Gtk.Embedding.Plug ( dist/build/Graphics/UI/Gtk/Embedding/Plug.hs, dist/build/Graphics/UI/Gtk/Embedding/Plug.o )

Graphics/UI/Gtk/Embedding/Plug.chs:120:6: error:
    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: error:
    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: error:
    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)
Failed to install gtk-0.13.9
cabal: Error: some packages failed to install:
gtk-0.13.9 failed during the building phase. The exception was:
ExitFailure 1

要安装此软件包,您需要" gtk2hsC2hs"并且类型错误在.chs个文件中,大概是从gtk2hsC2hs工具生成的。这是gtk2hsC2hs的已知问题吗?有没有其他人能够建立这个包?有人知道解决方案吗?

我在Mac OS X Yosemite(10.10.4)

$ gtk2hsC2hs --version
C->Haskell Compiler, version 0.13.13 (gtk2hs branch) "Bin IO", 27 May 2012

$ cabal --version
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library 

我已经完成了cabal update,所以我的所有套餐似乎都是最新的。我也试过构建hackage提供的一些旧版本,但我也遇到了同样的错误。

修改

生成的文件中的错误似乎都处理由gtk2hsC2hs生成的FFI导入。在文件的底部,我正在

foreign import ccall unsafe "gtk_plug_new"
  gtk_plug_new :: ((Ptr ()) -> (IO (Ptr Widget)))

似乎始终将Ptr()Maybe DrawWindow混为一谈。 那么生成的类型Ptr()是否不正确,或者它的使用是否不正确?

1 个答案:

答案 0 :(得分:21)

这有一个非常简单的解决方案。

cabal install gtk -fhave-quartz-gtk

如果记录得更好,那将会很好,但希望这将有助于其他任何最终处于类似情况的人