From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 4EAD3BBC4 for ; Wed, 15 Apr 2009 12:25:51 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AggDAMlS5UlRZ90wlGdsb2JhbACOLIdkAQEBAQkLCAkRA7wdg34G X-IronPort-AV: E=Sophos;i="4.38,431,1233529200"; d="scan'208";a="27716862" Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Apr 2009 12:25:51 +0200 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090415102550.PYT4080.mtaout02-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Wed, 15 Apr 2009 11:25:50 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090415102550.GTQO21638.aamtaout02-winn.ispmail.ntl.com@romulus.metastack.com> for ; Wed, 15 Apr 2009 11:25:50 +0100 Received: from Tenor (dynamic92.vpdn.csx.cam.ac.uk [131.111.7.92]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id n3FAPerv007212 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Wed, 15 Apr 2009 11:25:44 +0100 From: "David Allsopp" To: "OCaml List" Subject: Using Dynlink in the top level Date: Wed, 15 Apr 2009 12:25:27 +0200 Organization: MetaStack Solutions Ltd. Message-ID: <006901c9bdb4$81979e10$84c6da30$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acm9tH14XgepoEIZREi3L8ayU6Q8/A== Content-Language: en-gb x-cr-hashedpuzzle: AMB+ BvoY Bzp3 DL+2 DoAH EDh6 E8s/ FC8Z FFmE FVu2 F0ZT Hv66 IdL5 JdAJ KtUW Kvi2;1;YwBhAG0AbAAtAGwAaQBzAHQAQAB5AHEAdQBlAG0ALgBpAG4AcgBpAGEALgBmAHIA;Sosha1_v1;7;{AF570947-57A9-4822-8725-4489405C4FAC};ZAByAGEALQBuAGUAdwBzAEAAbQBlAHQAYQBzAHQAYQBjAGsALgBjAG8AbQA=;Wed, 15 Apr 2009 10:25:25 GMT;VQBzAGkAbgBnACAARAB5AG4AbABpAG4AawAgAGkAbgAgAHQAaABlACAAdABvAHAAIABsAGUAdgBlAGwA x-cr-puzzleid: {AF570947-57A9-4822-8725-4489405C4FAC} X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.0 c=1 a=grfWRssvD-3QMlDkmlEA:9 a=5VSYK8bElMtqORGEfxz2R9T8RZYA:4 a=birkmQ2h4YEA:10 X-Spam: no; 0.00; dynlink:01 dynlink:01 cmo:01 foo:01 cmo:01 foo:01 ocamlmktop:01 ocamlmktop:01 libs:01 unix:01 unix:01 exception:01 undefined:01 cma:01 cma:01 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: Exception: Dynlink.Error (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... David