From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8F9Kug2005357 for ; Thu, 15 Sep 2011 11:20:56 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApICAFLCcU6K54gDi2dsb2JhbABCpVGBfBQBAQEKCwsbJoFTAQEEATIBRQEFCwsYCRYPCQMCAQIBRQYNAQcBAYdztTCGdASTR4UcjBA X-IronPort-AV: E=Sophos;i="4.68,386,1312149600"; d="scan'208";a="119916839" Received: from rouge.crans.org ([138.231.136.3]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 15 Sep 2011 11:20:51 +0200 Received: from localhost (localhost.crans.org [127.0.0.1]) by rouge.crans.org (Postfix) with ESMTP id D6F6185E0; Thu, 15 Sep 2011 11:20:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at crans.org Received: from rouge.crans.org ([10.231.136.3]) by localhost (rouge.crans.org [10.231.136.3]) (amavisd-new, port 10024) with LMTP id 6MAAVGNEw3HU; Thu, 15 Sep 2011 11:20:50 +0200 (CEST) Received: from [152.81.12.138] (fleur.loria.fr [152.81.12.138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by rouge.crans.org (Postfix) with ESMTPSA id ACA5285D0; Thu, 15 Sep 2011 11:20:50 +0200 (CEST) Message-ID: <4E71C36D.5030207@glondu.net> Date: Thu, 15 Sep 2011 11:20:45 +0200 From: =?ISO-8859-1?Q?St=E9phane_Glondu?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13 MIME-Version: 1.0 To: Romain Bardou CC: jeremie@dimino.org, OCaml List 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> <4E71BC0C.1090607@lri.fr> In-Reply-To: <4E71BC0C.1090607@lri.fr> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] Link a .so/.dll dynamically On 09/15/2011 10:49 AM, Romain Bardou wrote: > Thanks, I tried the following combinations (with the bytecode version, > not the native one): > > -cclib -l$(DLLPATH)$(DLLNAME)$(DLLEXT) > -cclib -L$(DLLPATH) -cclib -l$(DLLNAME)$(DLLEXT) > -L$(DLLPATH) -cclib -l$(DLLNAME)$(DLLEXT) > -cclib -l$(DLLPATH)$(DLLNAME) > -cclib -L$(DLLPATH) -cclib -l$(DLLNAME) > -L$(DLLPATH) -cclib -l$(DLLNAME) > > Where $(DLLPATH) is the full path to my driver, such as /usr/lib/, > $(DLLNAME) is driver file name without the extension, such as driver, > and $(DLLEXT) is the extension, such as .so, such that the full .so path > is /usr/lib/driver.so. "-l$(DLLNAME)" refers to "lib$(DLLNAME).so". It is to be used with system shared libraries that use that convention. If you want to link to something not using this convention, using the full path (without -l/-L) might work on Linux, but keep in mind that not using lib$(DLLNAME).so might be on purpose (e.g. to suggest that this .so should be dlopen()-ed and not ld-linked). > None of them works; I still get the "undefined symbol" error. The option > does appear with ocamlobjinfo though. For instance, here is the result > of ocamlobjinfo on the .cma using the last command: > > Extra C object files: -lcryptoki -ldriver > Extra C options: -L/usr/lib/ > Extra dynamically-loaded libraries: -lcryptoki > > Shouldn't the -ldriver option appear in the extra dynamically-loaded > libraries as well? Where does cryptoki come from? > I might try Jeremie's more direct approach if everything else fails. Actually, I should have read more carefully your first mail... Jeremie's (and Daniel's) approach are clearly the way to go: write a C stub around dlopen() once and for all. I was instead thinking about drivers written in OCaml that were using system shared libraries in my replies. Cheers, -- Stéphane