Trying to statically link Gtk2Hs application (Windows XP, network drive)

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

On Fri, Aug 6, 2010 at 2:36 PM, Peter Schmitz
I am trying to statically link Gtk2Hs applications. ...
For anyone new to using [Haskell + Gtk2Hs + MS Windows], who, like me, is inclined to try to statically link the Windows binary (as I described in this thread), I've done some more research and came across this post: Re: [Gtk2hs-users] Making a static Windows executable with gtk2hs http://sourceforge.net/mailarchive/message.php?msg_id=1254152484.4588.632.ca... The gist is that, as desirable as it might seem to try to do so, it's just not a good idea, and things are going to work better overall relying on the DLLs. In the past, I had not noticed that http://sourceforge.net/projects/gtk2hs/ had a mailing list associated with it. I'm glad I found it. (and if this "don't statically link Windows Gtk2Hs binaries" advice is no longer current, please post. Thanks.) Hope this helps, -- Peter (keywords: Haskell Gtk2Hs Gtk+ static statically link linking Windows binary binaries executable application)

You may want to read http://gtk-win.sourceforge.net/home/index.php/en/Embedding In particular, they already have a template you may use when using NSIS to create an installer. Cheers! -- Felipe.

On Tue, Aug 10, 2010 at 6:58 PM, Felipe Lessa
You may want to read
http://gtk-win.sourceforge.net/home/index.php/en/Embedding
In particular, they already have a template you may use when using NSIS to create an installer.
Cheers!
-- Felipe.
Felipe, Thanks very much for mentioning this; looks great. -- Peter
participants (2)
-
Felipe Lessa
-
Peter Schmitz