(* Simple hello-world OCaml GTK program for Lablgtk. You can compile it like this: ocamlfind ocamlc -g -package lablgtk2 -linkpkg gtkhello.ml -o gtkhello or substitute `ocamlopt` for `ocamlc` for a native executable. You may previously need to run sudo apt-get install ocaml-findlib liblablgtk2-ocaml-dev *) (* http://osdir.com/ml/lang.ocaml.lib.gtk/2004-08/msg00007.html explains that, unless you include `lablgtk.cma` in your link line before this code, and also fail to do `GtkMain.Main.init ()`, it will first warn: (process:10432): Gtk-WARNING **: Screen for GtkWindow not set; you must always set a screen for a GtkWindow before using the window and then segfault. None of the examples in /usr/share/doc/liblablgtk2-ocaml-doc/examples/ invoke `GtkMain.Main.init`, so presumably you have to link them with `lablgtk.cma`? But it doesn’t solve the problem to add `lablgtk.cma` to the compilation command above; the generated executable still segfaults. *) let _ = GtkMain.Main.init () in let w = GWindow.window ~width:200 ~height:150 ~title:"hello, world" () in let _ = w#connect#destroy ~callback:GMain.quit in let _ = w#show () in GMain.main()