Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Pre-compiled ocaml binary for windows
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-12-09 (11:54)
From: Mauricio Fernandez <mfp@a...>
Subject: Re: [Caml-list] Re: Pre-compiled ocaml binary for windows
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:
> 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: %s@." (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  -