On Tue, Dec 07, 2010 at 10:49:14AM +0100, Alain Frisch wrote: > On 12/07/2010 10:42 AM, Sylvain Le Gall wrote: >>> An option could be to ship a minimalistic main program, which simply >>> dynlinks .cmxs files given on its command line. >>> >> >> You mean like ld.ocaml: >> https://forge.ocamlcore.org/projects/ld-ocaml/ > > Or just something like: > > let () = > try > for i = 1 to Array.length Sys.argv - 1 do > Dynlink.loadfile Sys.argv.(i) > done > with exn -> > Format.eprintf "Uncaught exception: %...@." (Printexc.to_string exn) > > (untested, and you probably want to print the stack trace as well)
This approach is not exactly convenient because the list of cmxs to be loaded can easily get very long... ld.ocaml does a little more than that: it first builds a catalog of available cmxs and then tries to satisfy the dependencies from the "root" cmxs, both in terms of imported interfaces and implementations. It thus allows multiple library versions to coexist, since it operates with signature digests instead of filenames. This is similar to (C) library sonames, but safer because signature digests are intrinsically so. There are other subtleties to building the dynamic loader: it has to contain the libs it's linked against in full and has to avoid duplicated module loading by tracking which modules are already available. ld.ocaml uses GNU BFD to extract the cmxs header, so it should only need minor tweaks (essentially in the build system) to work on Windows. -- Mauricio Fernandez - http://eigenclass.org _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs