Building ghc applications using Tcl/Tk under Win32

Building ghc-compiled applications under Win32 that calls upon Tcl/Tk will not work out of the box. This note outlines what you need to do in order to make it work.

The problem

Starting with 4.03, ghc dropped the dependency on the Cygwin DLL for the binaries that it produces. An upshot of this change is that working with code that uses the Cygwin DLL is not going to work (most of the time.) One main reason for the incompatibility is that you're combining code (in object or DLL form) that uses a separate C run-time libraries, which causes Bad Things to happen.

The cygwin B20.1 distribution comes with Tcl/Tk 8.0 included, DLLs which (naturally) have been compiled up to depend on the cygwin DLL. For reasons 'outlined' in the previous paragraph, using these Tcl/Tk DLLs from ghc-compiled code is not going to work very well.

The solution

To avoid depending on the Tcl/Tk that comes with the Cygwin dist, here's what you need to do: Notice that there's nothing inherently Tcl/Tk specific with the above sequence of tasks. Indeed, the procedure is a general recipe for generating ghc (and 'gcc -mno-cygwin)-friendly import libraries from any old Win32 DLLs.
Sigbjorn Finne <sof@dcs.gla.ac.uk>