Re: Shared libraries from caml

Xavier Leroy (Xavier.Leroy@inria.fr)
Mon, 21 Oct 1996 16:42:34 +0200 (MET DST)

From: Xavier Leroy <Xavier.Leroy@inria.fr>
Message-Id: <199610211442.QAA12172@pauillac.inria.fr>
Subject: Re: Shared libraries from caml
To: Leszek.Holenderski@gmd.de (Leszek Holenderski)
Date: Mon, 21 Oct 1996 16:42:34 +0200 (MET DST)
In-Reply-To: <v01520d05ae8be16f23ce@[129.26.10.139]> from "Leszek Holenderski" at Oct 17, 96 01:33:45 pm

> Is there any way to produce a sunos and/or solaris shared library from a
> caml module? Preferably in Caml Special Light, but Objective Caml will also
> do.
> In fact, I'm interested in a more specific problem. Could I use csl or
> ocaml to produce input for the Tcl "load" command? Has anybody tried it
> yet?

Dynamic linking of Objective Caml modules inside an Objective Caml program
is not completely impossible, but requires a lot of work. There are
global tables in the runtime that collect infos on all the Caml modules
linked in the application. These tables are currently fixed-size and
built at link-time. In the presence of dynamic linking, these would
need to be made extensible and updated correctly after dynamic linking.

Dynamic linking of O'Caml modules inside an arbitrary program (e.g. tcl)
is even harder. The whole Objective Caml runtime needs to be embarked
somehow. Also, if you don't have no control over the program that does
the dynamic linking, it's very hard to perform the correct
initializations, both of the module and of the runtime system itself.

It would be much easier to link Tcl into an O'Caml program that has
already all O'Caml modules statically linked. The callback Tcl -> O'Caml
is not too hard to do, see CamlTk4 for an example.

- Xavier Leroy