Here is a small howto about installing LablGtk2 on Win32
The binary distribution includes the lablglade, lablrsvg, and
0) Both MSVC and mingw versions of ocaml 3.11 should work.
If you want to do custom linking (either ocamlc -custom, or ocamlopt),
get a recent version of flexdll. Standard ocamlc linking only
1) Install the gtk2 libraries and dependencies.
This binary distribution was built using the "bundle" package at
(mirrors list at: ftp://ftp.gnome.org/pub/gnome/MIRRORS)
Just follow the instructions in the README file inside the package.
If you want to use the extension libraries (currently lablglade,
lablrsvg and lablgnomecanvas are supported), you must also install
the (numerous) dependencies. Here is what was used during
libglade-2.6.4 (requires libxml2)
libgnomecanvas-2.30.1 (requires libart_lgpl)
librsvg-2.32.1 (requires libcroco and libgsf)
If you want to do custom linking, you need also the dev packages.
All of these are available in the above win32 and
The distribution was compiled using the gtk+ bundle of 20120208,
but other versions should work too.
After unzipping all those archives in a common location (e.g. c:\Gtk),
it may be a good idea to go to c:\Gtk\bin and run
chmod +x *.dll
as some of the exta DLL's do not have the execution flag set.
Also, do not forget to add this binary directory to your path.
Open Control Panel/User account/Environment variables, and edit
either the personal or system variable Path to add c:\Gtk\bin.
If you cannot modify system variables directly, you can override
them by adding a fresh variable to your own environment:
Variable name: Path
2) Install lablgtk2 binaries and scripts inside the OCaml distribution
bin/* -> bin
lib/site-lib/lablgtk2 -> lib/site-lib/lablgtk2
Then edit lib/ld.conf, and add the line
<path to ocaml>\lib\site-lib\lablgtk2
3) If your distribution is newer than 4.00.0, go to the
lib/site-lib/lablgtk2 directory and execute
You must also do that everytime you update your OCaml distribution.
This will recompile the ocaml part of the library (the C part is
It may fail on the native code version (using ocamlopt) if the
assembler is not on your path. Look in the Objective Caml windows
documentation for what is needed, and check that you have a working
installation by compiling and linking a trivial program.
Note also that the autodection for mingw is not fool-proof
(lablgtk2 has to be installed at the expected location), so
if the OCaml port annouced by build.ml is not the right one, you
should specify it by hand inside build.ml.
4) Test in examples
See also the "Windows port" section of the main LablGtk2 README for
important remarks on threads on Windows.
5) For custom linking or native code, you need to use the export
libraries in the above DLL package. There is not default place to
put them, so you should specify that at link time:
ocamlopt -ccopt "-LC:/gtk/lib" -I +lablgtk2 lablgtk.cmxa \
gtkInit.cmx testgtk.ml -o testgtk.exe
Again, if this fails you must make sure that your ocamlopt really works,
and that all paths are correctly specified.
Full compilation with MSVC or mingw (for the brave)
0) You will need the MSVC or mingw version of ocaml 3.11 or more,
and cygwin development tools. You must also install flexdll
(at least 0.7) from
(Flexdll is already included in the OCaml 4.00.0 installer)
1) Install Gtk 2: use the precompiled binaries available at
This time you need the developper version.
Do NOT even try to compile it yourself from scratch.
Try to compile a small hello-gtk.c (see the tutorial page on
http://www.gtk.org) before going further.
You may unzip optional libraries available from
For example to have GtkSourceView 1 support, you have to unzip :
If you need to check that all dependencies are installed, use
pkg-config --libs gtksourceview-1.0
and see if an error is reported.
3) For MSVC, copy config.make.msvc to config.make, and edit it
to set GTKROOT.
On Mingw you should be able to run the configure script:
If you do want to perform configuration time Gtk C tests the define
CYGWIN=nobinmode before running ./configure.
The rationale behind CYGWIN=nobinmode is that pkg-config is a
native windows program which outputs \r\n instead of usual unix \n.
The CYGWIN variable forces the shell to strip down all \r from
command answers. (But the tests may still fail for other reasons.)
4) Simply do "make" and "make opt" for the native version.
5) Install ("make install" or "make old-install") and test.