基本问题:
我试图在OSX 10.10.4上使用标准mac指令安装Haskell的gtk
包。具体来说,我想运行threadscope
,所以我需要gtk
。homebrew
和gtk buildtools
的早期阶段工作良好,但当我
cabal install gtk
或
cabal install --with-gcc=gcc-4.8 gtk
我得到以下编译错误:
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:
在我将Haskell平台从ghc 7.8.4
更新到ghc 7.10.2
之前,我已经安装并运行了Haskell的gtk
库和threadscope
应用程序。起初,我假设安装冲突,但我多次使用彻底的删除说明从系统中删除Haskell平台,并重新尝试安装threadscope
,但没有成功。我甚至使用homebrew
删除并重新安装了底层gtk+
和相关软件包,仍然没有成功。
我不确定类型Ptr ()
和Maybe DrawWindow
起源于何处,因此冲突可能来自何处。任何关于什么可能会出错的想法将是欢迎的!
也许你可以尝试用这一行安装GTK
cabal install gtk -fhave-quartz-gtk
在edsko的博客中有一个安装GTK和threadscope的方法:
http://www.edsko.net/2015/03/09/sandboxes-revisited/搜索"GTK sandbox"
我能够使用上面的指令在ghc-7.10.2中构建threadscope。
我使用的具体命令:
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
沙箱中安装的包的具体版本:
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