سؤال

I wrote little app using gtk2hs on Linux and it works great. Latter I tryed to run that same app on Windows (xp, 7) but with no success. I installed:

  1. haskell platform for win
  2. gtk2hs all in one bundle in path with no spaces and set %PATH% to its /bin folder
  3. cabal install gtk2hs-buildtools
  4. cabal install gtk
  5. ghc --make -O2 Main.hs

And everything compiles and links OK. When trying to run that app it says:

c:\wordtrend>Main
(Main.exe:3228): GLib-GObject-CRITICAL **: gtype.c:2708: You forgot to call g_ty
pe_init()
(Main.exe:3228): GLib-GObject-CRITICAL **: gtype.c:2708: You forgot to call g_ty
pe_init()
(Main.exe:3228): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: as
sertion `G_TYPE_IS_INTERFACE (interface_type)' failed
(Main.exe:3228): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertio
n `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(Main.exe:3228): GLib-GObject-CRITICAL **: gtype.c:2708: You forgot to call g_ty
pe_init()
(Main.exe:3228): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertio
n `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(Main.exe:3228): GLib-GObject-CRITICAL **: gtype.c:2708: You forgot to call g_ty
pe_init()
(Main.exe:3228): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertio
n `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(Main.exe:3228): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OB
JECT (object_type)' failed
Segmentation fault/access violation in generated code

I dont know where to start from.

هل كانت مفيدة؟

المحلول

SOLVED: So it appears there must be no commands before gtk2hs:initGUI function on Windows.

Code below works on Linux but compiles and chrases on Windows:

main :: IO ()
main = do
  someCommand  -- this command must come after initGUI to run
  initGUI
  ...
  mainGUI

So don't put any commands before initGUI command.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top