English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
ocamlopt and *using* DLLs
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-05-27 (01:48)
From: Robert Roessler <roessler@r...>
Subject: Re: [Caml-list] ocamlopt and *using* DLLs
Nicolas Cannasse wrote:

> The main problem is that your DLL need to call Ocaml API, which it is linked
> with.
> In bytecode there is no problem since the whole API is inside ocamlrun.dll
> so your DLL and ocamlrun.exe will simply use this API dll together.
> In native compilation however there is no more ocamlrun.dll, since the API
> is staticly linked into your executable. That means that your DLL that was
> working in bytecode will load ocamlrun.dll and call it while your executable
> is calling staticly linked API. This will result quite quickly in a crash
> since ocamlrun.dll is not initialized correctly.
> The only possible way to get the DLL working is to patch it so it loads its
> API inside your.exe and not inside ocamlrun.dll. But then you will need a
> different version of the DLL for each application (!). It would be nice if
> OCaml could provide the equivalent of ocamlrun.dll for the native
> compilation mode.

Thanks for the explanation of the key difference between the models,

I have this running just fine now, and it is not really as grim as you
make it sound above. :)  Since my DLL really only exists to provide an
interface between OCaml and C-land, I just followed the model used by
LablGTK, and build that interface one of two ways: "dllscintilla.dll"
for bytecode, and "libscintilla.lib" for native.

Robert Roessler