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
[Caml-list] dynlink and toplevel
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-06-03 (15:19)
From: James Scott <j.scott@r...>
Subject: [Caml-list] dynlink and toplevel

Hi All, 

we're doing some work where it's useful to use Dynlink in the
toplevel, but we've run into a snag: if the Dynlink-loaded module
refers to modules loaded by '#load' or on the command line, they're
not resolved. But if they're put into a 'custom' toplevel they are, e.g.

$ cat 
let dynload_helper_ref = ref (None: int option)

let doit fname =
  let _ = Dynlink.init () in
  let _ = Dynlink.loadfile fname in

$ cat 
Loader.dynload_helper_ref := Some 1

$ cat
let _ = Loader.doit "Loadee.cmo" ;;

$ ocamlc -c
$ ocamlc -a -o llib.cma 
$ ocaml dynlink.cma llib.cma
 (Dynlink.Linking_error ("Loadee.cmo", Dynlink.Undefined_global "Loader")).

But this works:

$ ocamlmktop dynlink.cma llib.cma
$ ./a.out <
        Objective Caml version 3.07+2

# - : int option = Some 1

This was a bit of a surprise as I was expecting the two load semantics
to be identical... but is there any way round it?


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: