Clone wiki

clutter-ocaml / Home


This is the main page for the OClutter project which projects OCaml bindings for the Clutter Project. Included are bindings for the main clutter library, the clutter-cairo library, and the cogl API.


You will need to resolve the following dependencies before installing the OClutter bindings.

  • OCaml: >= 3.10 (uses ocamlbuild)
  • clutter-0.8
  • clutter-cairo-0.8: I decided to package clutter and clutter-cairo together for my bindings. This was mostly just selfish and lazy, but I'v heard rumors that the clutter project might also be doing this for the next version.
  • gtk+-2.0: this is because of lablgtk2 (see below)
  • cairo: required for clutter-cairo
  • lablgtk2: This is a very annoying dependency. The umbrella of lablgtk2 extends to gobject which is required by my bindings. I'm left with the option of re-implementing the gobject bindings or adding a dependency on lablgtk. There is also a GdkPixbuf dependency that is resolved through lablgtk.
  • ocaml-cairo


Assuming all of the required dependencies are installed, you should be able to proceed with the following:

$ hg clone
$ cd clutter-ocaml
$ autoconf
$ ./configure
$ make
$ make install


The best I have at this point is the ocamldoc generated documentation. I never went to the trouble of writing .mli files so there are some internal things that shouldn't appear. I will try to get a chance to clean this up.


A file called "" could be compiled as follows:

$ ocamlfind ocamlopt -package clutter -c

$ ocamlfind ocamlopt -linkpkg -package clutter -o example.opt example.cmx -cclib "`pkg-config --libs 
clutter-0.8`" -cclib "`pkg-config --libs clutter-cairo-0.8`"

Project Status

I'm pretty confident that there are problems with the memory management so I suspect a person might run into memory leaks. It has simply not seen enough real world usage.

There are also some problems with the bindings that I would like to fix but have not gotten around to. Mostly this is in the object interface side of things where things are not totally worked out.

In addition, it is not under "active development". That is not to say it is abandoned. I'm just not using it for a project right now, so there are unlikely to be any fixes or enhancements coming down the pipe in the near term. I'm happy to take patches or other contributions.

Please let me know if you are using OClutter and about your experience.

Getting Started

Check out the many examples located in the examples and tests directories.

Here is a relatively simple example:

open Clutter

let _ =
  let stage = ClutterStage.get_default () in

  let group = ClutterGroup.create ()
  and group2 = ClutterGroup.create () in

  let actor1 = ClutterTexture.create ~filename:"./redhand.png" ~x:0 ~y:0 ()
  and actor2 = ClutterTexture.create ~filename:"./redhand.png" ~x:200 ~y:0 () in
  let actor3 = ClutterTexture.create ~filename:"./redhand.png" ~x:0 ~y:0 ()
  and actor4 = ClutterTexture.create ~filename:"./redhand.png" ~x:200 ~y:0 () in
  group#add_many [|actor1#as_actor; actor2#as_actor|];
  group2#add_many [|actor3#as_actor; actor4#as_actor|];
  stage#add_actor group;
  stage#add_actor group2;
  group#set_position ~x:100 ~y:100;
  group#set_rotation `X_AXIS ~angle:80. ~x:(group#width / 2)
    ~y:(group#width / 2) ~z:(-0);
  group2#set_position ~x:100 ~y:200;
  group2#set_rotation `X_AXIS ~angle:80. ~x:(group#width / 2)
    ~y:(group#width / 2) ~z:0;

  clutter_main ()

The result is show below:

Simple Example