Merge remote branch 'origin/master'
[ghc-hetmet.git] / docs / users_guide / win32-dlls.xml
index eaa3d38..44f589a 100644 (file)
@@ -209,15 +209,6 @@ make-sessions running under cygwin.
 </title>
 
 <para>
-<emphasis>Making Haskell libraries into DLLs doesn't work on Windows at the
-moment; we hope to re-instate this facility in the future
-(see <xref linkend="using-shared-libs"/>).  Note that
-building an entire Haskell application as a single DLL is still supported: it's
-       just multi-DLL Haskell programs that don't work.  The Windows
-       distribution of GHC contains static libraries only.</emphasis></para>
-
-<!--
-<para>
 <indexterm><primary>Dynamic link libraries, Win32</primary></indexterm>
 <indexterm><primary>DLLs, Win32</primary></indexterm>
 On Win32 platforms, the compiler is capable of both producing and using
@@ -226,6 +217,33 @@ section shows you how to make use of this facility.
 </para>
 
 <para>
+There are two distinct ways in which DLLs can be used:
+<itemizedlist>
+  <listitem>
+    <para>
+      You can turn each Haskell package into a DLL, so that multiple
+      Haskell executables using the same packages can share the DLL files.
+      (As opposed to linking the libraries statically, which in effect
+      creates a new copy of the RTS and all libraries for each executable
+      produced.)
+    </para>
+    <para>
+      That is the same as the dynamic linking on other platforms, and it
+      is described in <xref linkend="using-shared-libs"/>.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+      You can package up a complete Haskell program as a DLL, to be called
+      by some external (usually non-Haskell) program. This is usually used
+      to implement plugins and the like, and is described below.
+    </para>
+  </listitem>
+</itemizedlist>
+</para>
+
+<!--
+<para>
 Until recently, <command>strip</command> didn't work reliably on DLLs, so you
 should test your version with care, or make sure you have the latest
 binutils. Unfortunately, we don't know exactly which version of binutils
@@ -427,9 +445,7 @@ foreign export stdcall adder :: Int -> Int -> IO Int
 </para>
 <programlisting>
 // StartEnd.c
-#include <Rts.h>
-
-extern void __stginit_Adder(void);
+#include &lt;Rts.h&gt;
 
 void HsStart()
 {
@@ -438,10 +454,7 @@ void HsStart()
 
    // Initialize Haskell runtime
    char** args = argv;
-   hs_init(&argc, &args);
-
-   // Tell Haskell about all root modules
-   hs_add_root(__stginit_Adder);
+   hs_init(&amp;argc, &amp;args);
 }
 
 void HsEnd()
@@ -499,7 +512,7 @@ HsStart
 End Sub
 
 Public Sub Test()
-MsgBox "12 + 5 = " & Adder(12, 5)
+MsgBox "12 + 5 = " &amp; Adder(12, 5)
 End Sub
 </programlisting>
 <para>
@@ -522,7 +535,7 @@ End Sub
 // Tester.cpp
 #include "HsFFI.h"
 #include "Adder_stub.h"
-#include <stdio.h>
+#include &lt;stdio.h&gt;
 
 extern "C" {
     void HsStart();
@@ -547,6 +560,8 @@ $ tester
 12 + 5 = 17
 </screen>
 
+</sect3>
+
 </sect2>
 
 </sect1>