阴谋集团安装 gtk 失败

Cabal install gtk failing

我正在尝试通过 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() 不正确,还是用法不正确?

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

cabal install gtk -fhave-quartz-gtk

如果这能有更详细的记录就好了,但希望这能帮助其他遇到类似情况的人