Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 Loader.ml 
let dynload_helper_ref = ref (None: int option)

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


$ cat Loadee.ml 
Loader.dynload_helper_ref := Some 1

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

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


But this works:

$ ocamlmktop dynlink.cma llib.cma
$ ./a.out < Test.ml
        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?

James 

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners