caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Romain Bardou <bardou@lri.fr>
To: "Stéphane Glondu" <steph@glondu.net>
Cc: jeremie@dimino.org, OCaml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Link a .so/.dll dynamically
Date: Thu, 15 Sep 2011 10:49:16 +0200	[thread overview]
Message-ID: <4E71BC0C.1090607@lri.fr> (raw)
In-Reply-To: <4E70DCC4.1030102@glondu.net>

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,
>

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.

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?

I might try Jeremie's more direct approach if everything else fails.

Cheers,

-- 
Romain Bardou

  reply	other threads:[~2011-09-15  8:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-14 15:00 Romain Bardou
2011-09-14 15:35 ` Benedikt Meurer
     [not found] ` <83695D27-A767-438A-B909-6864D1A655FE@googlemail.com>
2011-09-14 15:56   ` Romain Bardou
2011-09-14 15:59     ` Benedikt Meurer
2011-09-14 16:03       ` Romain Bardou
2011-09-14 16:07         ` Jérémie Dimino
2011-09-14 16:07     ` Stéphane Glondu
2011-09-14 16:12       ` Romain Bardou
2011-09-14 16:34         ` Stéphane Glondu
2011-09-14 16:42           ` Romain Bardou
2011-09-14 16:56             ` Stéphane Glondu
2011-09-15  8:49               ` Romain Bardou [this message]
2011-09-15  9:20                 ` Stéphane Glondu
2011-09-15  9:23                   ` Romain Bardou
2011-09-15  9:05               ` Romain Bardou
2011-09-14 16:15 ` Jérémie Dimino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E71BC0C.1090607@lri.fr \
    --to=bardou@lri.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=jeremie@dimino.org \
    --cc=steph@glondu.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).