From: John O'D. <jt...@dc...> - 2009-09-30 14:51:28
|
Hi, Background: I'm trying to make a standalone Windows executable, so it will run on a Windows machine that doesn't have a lot of Haskell packages already installed. The program uses gtk2hs. My initial attempts led to a program that, when launched, gets a dialog box saying some DLLs are missing. Several people (thank you!) gave the same advice: copy the DLLs that are needed into the folder that contains an executable, and then, when it launches, Windows will look first for the DLLs in that folder. This is indeed what is supposed to happen, according to what little documentation I've been able to find, but it doesn't work. According to my experiments, it's not enough for a DLL to be located physically in the same folder as the application that needs it. If you put it there, the application just silently hangs and then dies (without the DLL in the folder, a dialog box appears saying the DLL is missing). Apparently, the DLL needs to be in the same place in the file system that it was when the application was compiled. Is that correct? I hope not! An alternative approach would be a static build, instead of dynamic linking. I've tried compiling the program with ghc specifying the -static flag, but it still doesn't produce a static compilation. Was gtk2hs was built for Windows without -static? I'm using the binary Windows installation of gtk2hs from its web page. Any suggestions would be very welcome! Does there exist a static build of gtk2hs for Windows? Is it possible to compile a Windows program on one machine and execute it on another? Thanks, John O'Donnell -----Original Message----- From: Axel Simon [mailto:Axe...@en...] Sent: 28 September 2009 14:39 To: John O'Donnell Cc: gtk...@li... Subject: Re: [Gtk2hs-users] Making a static Windows executable with gtk2hs On Mon, 2009-09-28 at 14:28 +0100, John O'Donnell wrote: > Hi, > > > > I have a Haskell program that uses gtk2hs, and would like to make a > standalone Windows executable from it (running ghc-6.10.3 and > gtk2hs-0.10.1). The program compiles ok with the –static ghc linker > option, and the program runs fine on a Windows machine that has ghc > and gtk2hs installed, but then when the executable is carried over to > another Windows machine that doesn’t have gtk2hs installed locally, it > fails to launch. A dialogue box says it can’t find a DLL for > lib-cairo; when the dependency on cairo was removed it then complains > it can’t find DLL for lib-glade, and so on. > > > > Is there a way to produce a Windows executable for an application so > you can run it on a machine even if gtk2hs isn’t installed? I assume you don't even use the glade package? I don't quite know why the final executable has dependencies on packages that are not used. Windows will look for DLLs in the current directory and then on the $PATH. Thus, if you want to ship your application stand-alone, it will be easiest to copy your executable into a directory and with it all DLLs that are needed. Cheers, Axel. The University of Glasgow, charity number SC004401 |