Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Jérémie Dimino" <jeremie@dimino.org>
To: Romain Bardou <bardou@lri.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Link a .so/.dll dynamically
Date: Wed, 14 Sep 2011 18:15:12 +0200	[thread overview]
Message-ID: <1316016912.24759.29.camel@aurora> (raw)
In-Reply-To: <4E70C18F.3040304@lri.fr>

Le mercredi 14 septembre 2011 à 17:00 +0200, Romain Bardou a écrit : 
> Hello Caml-List,
> 
> I need to write a program which handles several devices. Each device has 
> a .so (linux) or .dll (windows) driver. Each of these DLL share the same 
> API, defined in C headers (api.h).
> 
> Here is what I figured I should do.
> - Write a binding for the library.
>    * OCaml part: mylib.ml, with externals.
>    * C part: wrapper.c, implementing the externals.
>      - Which itself includes api.h and may use the functions of the API.
> - Dynamically load this library using Dynlink.
> Later, the Mylib module will register each function of the API so the 
> program can call them, but that's not the issue (although if there is a 
> simpler way please tell).

You can also use dlopen and dlsym on unix, and 
LoadLibrary and GetProcAddress on windows.

-- 
Jérémie



      parent reply	other threads:[~2011-09-14 16:15 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
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 [this message]

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=1316016912.24759.29.camel@aurora \
    --to=jeremie@dimino.org \
    --cc=bardou@lri.fr \
    --cc=caml-list@inria.fr \
    /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