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 p8EGDaZq027704 for ; Wed, 14 Sep 2011 18:13:36 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AowBAIPRcE6yIGHOmWdsb2JhbABBp3sBAQEBAQgLCwcUJoFTAQEFMgEFQRALGAklDwJGBg0BBwKHdbVQhm4EmHmLbQ X-IronPort-AV: E=Sophos;i="4.68,381,1312149600"; d="scan'208";a="109075126" Received: from 19.mo1.mail-out.ovh.net (HELO mo1.mail-out.ovh.net) ([178.32.97.206]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Sep 2011 18:13:31 +0200 Received: from mail174.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo1.mail-out.ovh.net (Postfix) with SMTP id D736A10003D5 for ; Wed, 14 Sep 2011 18:14:13 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 14 Sep 2011 18:13:30 +0200 Received: from unknown (HELO ?138.231.81.43?) (romain%bardou.fr@138.231.81.43) by ns0.ovh.net with SMTP; 14 Sep 2011 18:13:30 +0200 Message-ID: <4E70D26A.10801@lri.fr> Date: Wed, 14 Sep 2011 18:12:26 +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: =?ISO-8859-1?Q?St=E9phane_Glondu?= CC: jeremie@dimino.org, OCaml List X-Ovh-Mailout: 178.32.228.1 (mo1.mail-out.ovh.net) References: <4E70C18F.3040304@lri.fr> <83695D27-A767-438A-B909-6864D1A655FE@googlemail.com> <4E70CEAE.8030807@lri.fr> <4E70D140.8030507@glondu.net> In-Reply-To: <4E70D140.8030507@glondu.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 15179945496080148995 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: -200 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeftddrfeduucetggdotefuucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmneculddquddttddm X-Validation-by: bardou@lri.fr Subject: Re: [Caml-list] Link a .so/.dll dynamically Le 14/09/2011 18:07, Stéphane Glondu a écrit : > On 09/14/2011 05:56 PM, Romain Bardou wrote: >> [...] >> ocamlopt -c -ccopt -fPIC wrapper.c >> ocamlopt -c mylib.ml >> ocamlmklib wrapper.o mylib.cmx -o mylib >> ocamlopt -c main.ml >> ocamlopt dynlink.cmxa main.cmx -o main >> CAML_LD_LIBRARY_PATH=. ./main mylib.cmxa >> >> But when Dynlink.load is called, it fails with the following error: >> >> error loading shared library: /home/.../mylib.cmxa: invalid ELF header >> >> I'm thinking this is because the .cmxa has not been compiled with the >> -shared option, but I don't know how to tell ocamlmklib to compile with >> the -shared option. > > You can turn the .cmxa generated by ocamlmklib into a .cmxs by calling > (for example): > > ocamlopt -shared -I . -linkall -o mylib.cmxs mylib.cmxa > > The .cmxs should then be loadable by Dynlink.load. Thanks, this solves the "native" part of my problem ! Now I need to figure out how to link this .so file. -- Romain Bardou