21

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

4

1 回答 1

23

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

cabal install gtk -fhave-quartz-gtk

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

于 2015-08-17T14:42:17.790 回答