From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q28GHJd3028153 for ; Thu, 8 Mar 2012 17:17:19 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUBAPDaWE/RVdS2kGdsb2JhbAApGqNMkUkIIgEBAQEJCQ0HFAQjggoBAQEEEgITGQEbEgsBAwwGBQsNDSEiAREBBQEKEgYTCAoJB4doCymcTwqLdIJxhTk/iHQBBQuQYwSVRY46PYQF X-IronPort-AV: E=Sophos;i="4.73,552,1325458800"; d="scan'208";a="135066888" Received: from mail-wi0-f182.google.com ([209.85.212.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 08 Mar 2012 17:17:12 +0100 Received: by wibhn6 with SMTP id hn6so720727wib.27 for ; Thu, 08 Mar 2012 08:17:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=Eq6GH/tlzvrvOQYF89up8c63ppKQL7gFbFOBV0oq+t4=; b=ec0qk9bsia+5i0mRJMk07xCU9sFbq0PuE3m7JIo4SCCrCBq2ASjk3amanI7ezkOrPX Ivv33zPgWGPzbk+09q8Oq+7JMTx7mu78tjSoRwzPiABuorzuWNviwbac3+k9AG6/it2e uqydjpaJK2wGGRpohrxj87cOKzk23bdHUM2z+cliurAEziDH9WRslO/9esBHL4WfnYmU R6HsKyF3jrW0HeERwaliyVnbjR5yiAcFt+TFtpD83pJbXsv2dMh32/ke9EandSH9+Xlc pu/D/XcA+KsmBBusWDCDwJf0ZOgQo4CWdN9jo1837WLE/KlEhoVLGSXjc0YUxwjyapyZ Muqw== Received: by 10.180.87.8 with SMTP id t8mr36435584wiz.15.1331223431733; Thu, 08 Mar 2012 08:17:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.200.85 with HTTP; Thu, 8 Mar 2012 08:16:30 -0800 (PST) In-Reply-To: References: <74F89B4A-9C34-4A33-8DAA-8A12CF9EF03B@polytechnique.org> From: Gabriel Scherer Date: Thu, 8 Mar 2012 17:16:30 +0100 Message-ID: To: Alan Schmitt Cc: caml-list list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q28GHJd3028153 Subject: Re: [Caml-list] state of native dynlink on os x This error is not Mac-related (I can reproduce it on my Debian). I believe it is a result from the "link-by-need" semantics of the .cma and .cmxa: loader.ml does not explicitly depend on test, so when producing the executable test.cmxa isn't linked (modules included .cm{x,}a, contrarily to .cm{x,o}, are only linked when they are a runtime dependency of one of the other modules). I can remove the error by either: - compiling to "test.cmx" instead of "test.cmxa" - or adding a dummy dependency in loader.ml: let () = ignore (Test.f) I am not familiar with the building of dynlink plugins (no idea what "-shared" does and whether you are expecting the compiled code for Test to end up linked inside "plugin.cmxs" instead of linked at executable compile time), so there may be another solution for this. But I remember other people mentioning this "explicit dependency" thing in the past; the dummy dependency is probably the right thing to do if you consider Test a library that come with the loader application and should be usable by all dynlinked module. If it is morally local to "plugin", there must be another approach. On Thu, Mar 8, 2012 at 3:16 PM, Alan Schmitt wrote: > On 8 mars 2012, at 12:13, Alan Schmitt wrote: > >> On 27 févr. 2012, at 16:43, Damien Doligez wrote: >> >>>> Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined? >>> >>> Looks like modules of the standard library, right ? >> >> Regarding this, should something special be done when dynlinking a file that depends on the standard library? I assume that dependencies are not automatically loaded, but should one load the standard library first? >> >> In other words, is this a bug in why3, or in ocaml? > > Trying to get to the bottom of this, here is what I've done. > > - Adapting the minimal example from http://caml.inria.fr/mantis/view.php?id=5093 I checked that I can load a plugin that uses a function from Random. > - I then tried to load a why3 plugin. It fails because it cannot find some symbol (_camlWhy3), and I could not find how to compile things to make sure why3.cmxa is linked with the plugin. > - Getting back to the basics, I tried to create a small archive of my own, which I would use in a plugin, and this is where I'm stuck. I have the following files: > > test.ml: > > let f () = "foo" > > plugin.ml: > > let s = Test.f () > let () = print_endline s > > loader.ml: > > let load f = >  try >    Dynlink.loadfile f >  with Dynlink.Error e -> print_endline (Dynlink.error_message e) > > let () = load "plugin.cmxs" > > to build everything, I do (I tried adding test.cmxa everywhere, to no avail. Everything lives in the same, current directory): > > ocamlopt.opt -a -o test.cmxa test.ml > ocamlopt.opt -c -linkall -o plugin.cmx test.cmxa plugin.ml > ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs > ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native > > When I run "./loader.native", I get: > > no implementation available for Test > > I googled this error and could only find references to problem related to the (deprecated) Dynlink.add_interfaces, which is not even supposed to work natively. > > What am I doing wrong? > > Thanks, > > Alan > > > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >