Re: lablgtk2 and ocamlc

Florent Monnier <[email protected]> Mon, 20 Jul 2009 23:19:16 +0200
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
Li Qiao a écrit :
> Hi all,
>
> I am new to lablgtk, sorry if this question is too native.
>
> When trying on the examples, I can run the examples with lablgtk2 ??.ml.
> However, when I try using the ocamlc command, it doesn't work. For example,
> for the about.ml example inside the distribution, command "ocamlc -g -I
> ../src lablgtk.cma about.ml -o about" (stated in the code) gives me an
> error of
>
> "File "about.ml", line 14, characters 4-24:
> Unbound value GWindow.about_dialog"
>
> But I think lablgtk has installed in my machine since lablgtk2 command
> correctly run the example.
> Anyone has any idea why this is so? Cos I may prefer the ocamlc command
> because I want to link to other ocaml files in my application.
>
> Thank you very much!
> Qiao Li

If the command lablgtk2 works (without being preceded by a full path to the 
command), it means that lablgtk2 is installed in your system (on unix it 
means that this program is located in one of the directory contained in the 
environment variable $PATH, probably /usr/bin so /usr/bin/lablgtk2). So in 
the command line to compile you shouldn't use -I ../src but -I +lablgtk2
The '+' sign replaces the base path of the installed ocaml libraries, so 
+lablgtk2 stands for /usr/lib/ocaml/lablgtk2
so your full command line should be:
ocamlc -g -I +lablgtk2 lablgtk.cma about.ml -o about
The path ../src is for when the library is not installed, but just compiled in 
this relative directory.