Re: Compiling examples

Jacques Garrigue <[email protected]> Mon, 22 Nov 2010 11:21:59 +0900
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
On 2010/11/22, at 5:19, Serge Le Huitouze wrote:
> Instead of asking newbie questions here (which are not answered anyway
> ;-), I decided to take it the long way and compile all examples to see
> whether they cover what I'm looking for...

Probably the right way to go :-)

> However, I ran into trouble as early as the second (in lexicographic
> order) file, namely "accel_tree.ml"!
> 
> First, it lacks a comment in the header giving the full command line
> to compile it.
> So I thought I'd try the same command as for "about.ml":
> * ocamlc -g -I ../src lablgtk.cma accel_tree.ml -o accel_tree
> Which gave me the (not so unusual) warning:
> * File "accel_tree.ml", line 80, characters 2-32:
> * Warning S: this expression should have type unit.

If you look at the README file, you will see that the standard way to compile
examples is:

  ocamlc -I +lablgtk2 -w s lablgtk.cma gtkInit.cmo ???.ml -o ???

With this command line the above warning disappears, and you link in
gtkInit.cmo, which is necessary for most examples (but not for about.ml).

> Executing it terminates immediately with the cryptic message:
> * Fatal error: unknown C primitive `ml_gtk_tree_view_get_visible_range'

Checklist:
* have you installed lablgtk2 in the standard location?
  (if the stubs are in a shared library, it needs to be visible from the ocaml runtime,
   and you might have an old version installed)
* what is the version of lablgtk2 you are using?
  (at least, with 2.14.2 the above function does exist, and the example runs
  correctly)

> Googling this primitive produced only one page:
> http://old.nabble.com/Patch-to-add-binding-for-gtk_tree_view_get_visible_range-td26901400.html
> which didn't enlighten me much, even more so given that this message
> dates from December 2009, whereas file "accel_tree.ml" dates from
> August 2008...

It may happen that somebody add an example forgetting to add the support code,
but we try to avoid that...

Jacques