From mboxrd@z Thu Jan 1 00:00:00 1970 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 p8EGFHmh027978 for ; Wed, 14 Sep 2011 18:15:17 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtcFALDScE7VuiYS/2dsb2JhbABBhAxJoReBe3iBUwEBBQwXVhAJAhoCJgICLCsGiAyjNpIRDoEehDGBEQSkZg X-IronPort-AV: E=Sophos;i="4.68,381,1312149600"; d="scan'208";a="109075350" Received: from solaria.dimino.org ([213.186.38.18]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Sep 2011 18:15:12 +0200 Received: from aurora (localhost.localdomain [127.0.0.1]) by solaria.dimino.org (Postfix) with ESMTP id 8AD288004F; Wed, 14 Sep 2011 18:15:11 +0200 (CEST) Received: by aurora (Postfix, from userid 1000) id 70F7341EA6; Wed, 14 Sep 2011 18:15:12 +0200 (CEST) From: =?ISO-8859-1?Q?J=E9r=E9mie?= Dimino To: Romain Bardou Cc: caml-list@inria.fr Date: Wed, 14 Sep 2011 18:15:12 +0200 In-Reply-To: <4E70C18F.3040304@lri.fr> References: <4E70C18F.3040304@lri.fr> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.0.3- Message-ID: <1316016912.24759.29.camel@aurora> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p8EGFHmh027978 Subject: Re: [Caml-list] Link a .so/.dll dynamically 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