From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr 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 p8F967pK004489 for ; Thu, 15 Sep 2011 11:06:07 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AikCAFu/cU5XYqyimWdsb2JhbABCmRaMO4IQAQEBAQEICwsHFCaBUwEBBTIBBUARCxgJFg8JAwIBAgFFEwgCh3W1LIZ0BJkCi3E X-IronPort-AV: E=Sophos;i="4.68,386,1312149600"; d="scan'208";a="109148636" Received: from 18.mo3.mail-out.ovh.net (HELO mo3.mail-out.ovh.net) ([87.98.172.162]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Sep 2011 11:06:00 +0200 Received: from mail91.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo3.mail-out.ovh.net (Postfix) with SMTP id 6DF3AFFC6EB for ; Thu, 15 Sep 2011 11:07:22 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 15 Sep 2011 11:05:59 +0200 Received: from unknown (HELO ?138.231.81.43?) (romain%bardou.fr@138.231.81.43) by ns0.ovh.net with SMTP; 15 Sep 2011 11:05:58 +0200 Message-ID: <4E71BFCC.7070008@lri.fr> Date: Thu, 15 Sep 2011 11:05:16 +0200 From: Romain Bardou User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110820 Icedove/3.1.12 MIME-Version: 1.0 To: caml-list@inria.fr X-Ovh-Mailout: 178.32.228.3 (mo3.mail-out.ovh.net) References: <4E70C18F.3040304@lri.fr> <83695D27-A767-438A-B909-6864D1A655FE@googlemail.com> <4E70CEAE.8030807@lri.fr> <4E70D140.8030507@glondu.net> <4E70D26A.10801@lri.fr> <4E70D789.6030309@glondu.net> <4E70D958.4030601@lri.fr> <4E70DCC4.1030102@glondu.net> In-Reply-To: <4E70DCC4.1030102@glondu.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 13832243306648824352 X-Ovh-Remote: 138.231.81.43 () X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfedvkedrtdduucetggdotefuucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucculddquddttddm X-Validation-by: bardou@lri.fr Subject: Re: [Caml-list] Link a .so/.dll dynamically Le 14/09/2011 18:56, Stéphane Glondu a écrit : > On 09/14/2011 06:42 PM, Romain Bardou wrote: >>>> Thanks, this solves the "native" part of my problem ! Now I need to >>>> figure out how to link this .so file. >>> >>> You mean, the equivalent of dllmylib.so? There is no such file in native >>> code: mylib.cmxs will contain the contents of mylib.cmxa and wrapper.o. >> >> No I mean the driver DLL for which Mylib is the binding. File >> dllmylib.so is linked correctly, but binding.c includes api.h, which is >> implemented in api.so, so I need to link with api.so as well. The whole >> point of my original question is: how can I design the program such that >> this api.so is loaded dynamically, because the user may want to choose a >> different driver everytime, or even change driver during execution. > > That would be a -cclib option passed to ocamlmklib. It embeds a -lXXX > option in the .cmxa that should be visible with a recent version of > ocamlobjinfo. You can check the result by running ldd on the .cmxs file. > > > Cheers, > Out of curiosity I redid the same tests on the native build, and the following works : ocamlmklib -cclib /usr/lib/driver.so wrapper.o mylib.cmx -o mylib It appears that the library is linked when "ocamlopt -shared" is called though, so the library is statically linked in the dynamically linked module. Which is fine actually, it does solve my problem. I guess I don't really need the bytecode version, but if there is a way to do it, please satisfy my curiosity ;) Thanks and cheers, -- Romain Bardou