English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Using Dynlink in the top level
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-04-15 (10:25)
From: David Allsopp <dra-news@m...>
Subject: Using Dynlink in the top level
Is there any way to allow modules loaded with Dynlink in the top-level to
have access to modules loaded using #load?

For example, suppose I have bar.cmo which depends on foo.cmo. If I say:

        Objective Caml version 3.11.0
# #load "dynlink.cma";;
# #load "foo.cmo";;
# Dynlink.openfile "bar.cmo";;

then I get:

 (Dynlink.Linking_error ("bar.cma", Dynlink.Undefined_global "Foo")).

I can work around this by either:

a) Using Dynlink.openfile instead of #load to load foo.cmo
b) Using ocamlmktop and pre-linking foo.cmo into a new top-level

Method a) would be fine except that Dynlink cannot load libraries like
unix.cma so ocamlmktop becomes the only (slightly tedious) alternative if
libs like unix.cma is required. Presumably the code for the top-level uses
for #load and Dynlink must be almost the same thing so it seems long-winded
to have use ocamlmktop all the time...