
I am trying to statically link Gtk2Hs applications. E.g., the Gtk2Hs demo ...\demo\hello\World.hs from the SourceForge tarball: http://sourceforge.net/projects/gtk2hs/files/gtk2hs/0.10.1/gtk2hs-0.10.1.tar... My failed link attempts are listed at the end of this mail, but first some notes about my configuration. I need to develop in a Windows XP environment, where the toolset (Haskell Platform, Cabal, gtk, Gtk2hs, etc.) is located on a network drive (H:) instead of C:. (I know this may be unusual, but I need to be able to use any one of several PCs for development, with one common tools tree.) It is okay for temp files to reside on C:, but otherwise I have: H:\proc\tools\Haskell Platform\2010.1.0.0\ H:\proc\tools\gtk\ H:\proc\tools\cabal\ etc. (Fyi, I set up Cabal for this environment with some kind help: http://www.haskell.org/pipermail/haskell-cafe/2010-July/thread.html#80930 ). The _dynamically_ linked World.exe runs okay: PATH is: PATH= H:\proc\tools\Haskell Platform\2010.1.0.0\bin; H:\proc\tools\cabal\bin; H:\proc\tools\gtk\bin; H:\proc\tools\Haskell Platform\2010.1.0.0\lib\extralibs\bin; H:\proc\tools\Haskell Platform\2010.1.0.0\mingw\bin H:\proc\dev\Gtk2Hs\demo\hello>ghc --make World.hs [1 of 1] Compiling Main ( World.hs, World.o ) Linking World.exe ... Process completed, Exit Code 0. I had to add the mingw\bin dir to PATH to get cpp (needed during "cabal install gtk"), and the extralibs dir to get alex (for "cabal install gtk2hs-buildtools"). I would like users to be able to run my statically linked apps without having to worry about .dll issues at runtime, and just by double clicking on the app in a Windows explorer (file system display) window. When I try that for this dynamically linked World.exe, I get the error dialog: World.exe - Unable To Locate Component The application has failed to start because libcairo-2.dll was not found. Reinstalling the application may fix this problem. I consulted the ghc user guide, and did some Googling. I am not sure if the static linking difficulty is due to needing to link with the gtk (non Haskell) code (i.e., http://www.gtk.org/download-windows.html and http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.20/gtk+_2.20.0-1_win32.... ), as perhaps alluded to in section "3. Static linking vs dynamic linking" in http://www.cs.virginia.edu/~wh5a/blog/Some%20GHC%20notes%20for%20myself.html (... The C libraries are not statically linked by default. To produce a completely static binary ...) or if it is just due in some way to my non-standard network drive configuration (ghc not finding some ".a" files library dirs to complete the static link, and so it defaults to dynamic linking?). Fyi, here are some of my dirs that have various *.a files: H:\proc\tools\cabal\cairo-0.11.0\ghc-6.12.1 H:\proc\tools\cabal\gio-0.11.0\ghc-6.12.1 H:\proc\tools\gtk\lib H:\proc\tools\Haskell Platform\2010.1.0.0\lib H:\proc\tools\Haskell Platform\2010.1.0.0\mingw\lib Other than PATH, I don't have any environment shell variable defined for searching a library path. Finally, here are my attempts to statically link: PATH is: PATH=H:\proc\tools\Haskell Platform\2010.1.0.0\bin;H:\proc\tools\cabal\bin;H:\proc\tools\gtk\bin;H:\proc\tools\Haskell Platform\2010.1.0.0\lib\extralibs\bin;H:\proc\tools\Haskell Platform\2010.1.0.0\mingw\bin H:\proc\dev\Gtk2Hs\demo\hello>ghc --make -static -optl-static World.hs [1 of 1] Compiling Main ( World.hs, World.o ) Linking World.exe ... H:\proc\tools\Haskell Platform\2010.1.0.0\mingw\bin\ld.exe: cannot find -lz collect2: ld returned 1 exit status Process completed, Exit Code 1. PATH is: PATH=H:\proc\tools\Haskell Platform\2010.1.0.0\bin;H:\proc\tools\cabal\bin;H:\proc\tools\gtk\bin;H:\proc\tools\Haskell Platform\2010.1.0.0\lib\extralibs\bin;H:\proc\tools\Haskell Platform\2010.1.0.0\mingw\bin H:\proc\dev\Gtk2Hs\demo\hello>ghc --make -optl-static -optl-pthread World.hs [1 of 1] Compiling Main ( World.hs, World.o ) Linking World.exe ... H:\proc\tools\Haskell Platform\2010.1.0.0\mingw\bin\ld.exe: cannot find -lz collect2: ld returned 1 exit status realgcc.exe: unrecognized option `-pthread' Process completed, Exit Code 1. Any advice, pointers, etc. would be appreciated. Thanks very much, -- Peter