<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2005/05/f7e5de978308cd1ac2f2aaed1788e34f"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2005-05-27T01:48:37"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs"
  prev="2005/05/8cf1db6105fd8dae18874f45311ed947"
  next="2005/05/ff17d1c954de2ba853ef42e9992815d1"
  prev-in-thread="2005/05/fc38fd9a87d630b7d9df42b16cfbaec0"
  prev-thread="2005/05/6bc8288e79ab9a5dc858b7fdb70117d6"
  next-thread="2005/05/9286991d81ae52bf3d33cf5e71230358"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="ocamlopt and *using* DLLs">
<msg 
  url="2005/05/a36fd4aef9cd201c1ad33f6b4cda255d"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2005-05-24T03:53:20"
  subject="ocamlopt and *using* DLLs">
<msg 
  url="2005/05/ea5f2ee9392f6d3c9e16ec04a76fbddb"
  from="Jacques Garrigue &lt;garrigue@m...&gt;"
  author="Jacques Garrigue"
  date="2005-05-24T04:30:04"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
<msg 
  url="2005/05/9911874e1ae1601791833b3fe0df85a6"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2005-05-24T06:38:18"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
<msg 
  url="2005/05/d756c60086dad92de4bcd0a7bf604a8c"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2005-05-24T07:11:36"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
<msg 
  url="2005/06/c3ffc54913b55d70b279663a47aa1f00"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2005-06-01T20:30:47"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
<msg 
  url="2005/06/3d049d9b338577fabcc04dfc9dcbab83"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2005-06-02T04:23:05"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
</msg>
</msg>
<msg 
  url="2005/05/ff17d1c954de2ba853ef42e9992815d1"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2005-05-27T01:49:01"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
</msg>
</msg>
</msg>
<msg 
  url="2005/05/87c5fe0e8212d87896c17081bc2d5289"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2005-05-27T02:11:55"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
<msg 
  url="2005/05/a90835e46a619e0296c0fb6edda3bd99"
  from="Anatoly Zaretsky &lt;anatoly.zaretsky@g...&gt;"
  author="Anatoly Zaretsky"
  date="2005-05-27T08:17:53"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
<msg 
  url="2005/05/0a214c2eefcf26ec113049096f0a4572"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2005-05-28T07:10:48"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2005/05/fc38fd9a87d630b7d9df42b16cfbaec0"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2005-05-24T05:07:06"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
<msg 
  url="2005/05/f7e5de978308cd1ac2f2aaed1788e34f"
  from="Robert Roessler &lt;roessler@r...&gt;"
  author="Robert Roessler"
  date="2005-05-27T01:48:37"
  subject="Re: [Caml-list] ocamlopt and *using* DLLs">
</msg>
</msg>
</msg>
</thread>

<contents>
Nicolas Cannasse wrote:

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

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

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
roessler@rftp.com
http://www.rftp.com

</contents>

</message>

