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 q28EOJ65023538 for ; Thu, 8 Mar 2012 15:24:19 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArYBAK+/WE/RVaC2kGdsb2JhbAApGoU1nhiIUQGIdwgiAQEBAQkJDQcUBCOCCgEBAQMBEgIPBBkBGxILAQMBCwYFCw0NHQICIgERAQUBChIGExIQh2MFCymcJgqLKEyCcYU+P4h0AQULj02BFgSCXZJoiySDFj2EBQ X-IronPort-AV: E=Sophos;i="4.73,552,1325458800"; d="scan'208";a="135041229" Received: from mail-gy0-f182.google.com ([209.85.160.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 08 Mar 2012 15:24:13 +0100 Received: by ghrr20 with SMTP id r20so300448ghr.27 for ; Thu, 08 Mar 2012 06:24:12 -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; bh=VHwosbii8VG6fRQGvr5RlKYT3fHaMUQawOXT6/owXeM=; b=Y+/TU4yloTfP92X/Bo7YvA5v4ZFr4jHd+Ny7mfBqMulQ2tcO8kbGg0cnqof2QWQdu1 I7ptCwHrsE4B1VKlz//FkBd3Qhc5+153PGfo/ngvaVtMIsSHPVhEg5K3SNcfrMJcqiw3 47tgqWWSl/an4A6Q1YumQ+dJJvD4me0ngUbj8jgtXaxdikiizB3cIbkGz26WLz8L3Psq 3k4Zm+h7caPBZ+lfWXWfX4HUj3Nuz8qr7IDMWjLqYKD1c22LjpVJNyeBwWgWg3ZnyNcY +uNqWlNbQmzC4iGAPAWSEzCCOJVjhySPbrYzZOLjPMQyFMdJMbxhqfH2L9FnT1VOX/4t GtlQ== Received: by 10.236.76.41 with SMTP id a29mr10193855yhe.117.1331216652208; Thu, 08 Mar 2012 06:24:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.25.4 with HTTP; Thu, 8 Mar 2012 06:23:52 -0800 (PST) In-Reply-To: References: <74F89B4A-9C34-4A33-8DAA-8A12CF9EF03B@polytechnique.org> From: Pierre-Alexandre Voye Date: Thu, 8 Mar 2012 15:23:52 +0100 Message-ID: To: Alan Schmitt Cc: caml-list list Content-Type: multipart/alternative; boundary=20cf303b40e3ac8b9604babc0780 Subject: Re: [Caml-list] state of native dynlink on os x --20cf303b40e3ac8b9604babc0780 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable In Mac Lion, i get : $ ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs ld: warning: -read_only_relocs cannot be used with x86_64 $ ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native File "loader.ml", line 1, characters 0-1: Error: Cannot find file dynlink.cmxa 2012/3/8 Alan Schmitt > On 8 mars 2012, at 12:13, Alan Schmitt wrote: > > > On 27 f=C3=A9vr. 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=3D5093 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 su= re > 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 () =3D "foo" > > plugin.ml: > > let s =3D Test.f () > let () =3D print_endline s > > loader.ml: > > let load f =3D > try > Dynlink.loadfile f > with Dynlink.Error e -> print_endline (Dynlink.error_message e) > > let () =3D 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 wo= rk > 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 > > --=20 --------------------- https://twitter.com/#!/ontologiae/ http://linuxfr.org/users/montaigne --20cf303b40e3ac8b9604babc0780 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable In Mac Lion, i get :

$ ocamlopt.opt -shared plugin.cmx test.cmxa -o = plugin.cmxs
ld: warning: -read_only_relocs cannot be used with x86_64$ ocamlopt.opt test.cmxa dynlink.cmxa loader.= ml -o loader.native
File "loader.ml", line 1, charac= ters 0-1:
Error: Cannot find file dynlink.cmxa

2012/3/8 Alan Schmitt <alan.schmitt@polytechnique.org>
On 8 mars 2012, at 12:13, = Alan Schmitt wrote:

> On 27 f=C3=A9vr. 2012, at 16:43, Damien Doligez wrote:
>
>>> Also, when running why3, I get some undefined symbols (_camlRa= ndom, _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 fil= e 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=3D5093 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 () =3D "foo"

plugin.ml:

let s =3D Test.f ()
let () =3D print_endline s

loader.ml:

let load f =3D
=C2=A0try
=C2=A0 =C2=A0Dynlink.loadfile f
=C2=A0with Dynlink.Error e -> print_endline (Dynlink.error_message e)
let () =3D 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 t= est.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 t= he (deprecated) Dynlink.add_interfaces, which is not even supposed to work = natively.

What am I doing wrong?

Thanks,

Alan



--
Caml-list mailing list. =C2=A0Subscription 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




--
-----------= ----------
https://twitter.com/#!/ontologiae/
http://linuxfr.org/users/montaigne

--20cf303b40e3ac8b9604babc0780--