Getting Cabal 1.1.1 working on Windows 98

The version of Cabal that comes with GHC (6.4 and 6.4.1) doesn't run on Windows 98 because of a missing SHGetFolderPathA function, so I thought I'd try to compile version 1.1.1 myself. I see that some work has been done in CVS for this problem, but I thought I'd post the changes I had to make to get 1.1.1 to work incase this is helpful to other people or to getting it fixed propoerly. I'm using MinGW 4.1, MSYS 1.0.10 and MSYS Developer Tool Kit 1.0.1. I've attached a patch against version 1.1.1. First, I tried compiling setup without any changes: $ make HCBASE=/c/ghc/ghc-6.4.1/bin/ setup ... Compiling Main ( Setup.lhs, dist/tmp/Main.o ) Linking ... dist/tmp/Distribution/Simple/Configure.o(.text+0xe41):fake: undefined reference to `SHGetFolderPath@20' make: *** [setup] Error 1 Ok, this seems to be because we need to pick either the A or W version. I'm not sure how to get this to happen automatically, but I guess we want the A version: $ diff ../cabal-1.1.1.orig/Distribution/Simple/Configure.hs Distribution/Simple /Configure.hs 256c256 < foreign import stdcall unsafe "SHGetFolderPath" ---
foreign import stdcall unsafe "SHGetFolderPathA"
Now, I try again: $ make HCBASE=/c/ghc/ghc-6.4.1/bin/ setup ... Skipping Main ( Setup.lhs, dist/tmp/Main.o ) Linking ... Yay, it compiled! Now I try to run it: $ make HCBASE=/c/ghc/ghc-6.4.1/bin/ config "The SETUP.EXE file is linked to missing export SHELL32.DLL:SHGetFolderPathA" (The message is GUI dialog box.) Ah, this is because SHGetFolderPathA is not in SHELL32.DLL on Windows 98, but in SHFOLDER.DLL. It is also in SHFOLDER.DLL on later versions, so this change should be safe: $ diff ../cabal-1.1.1.orig/GNUmakefile GNUmakefile 4c4 < GHCFLAGS= --make -Wall -fno-warn-unused-matches -cpp ---
GHCFLAGS= --make -Wall -fno-warn-unused-matches -cpp -lshfolder
Try again: $ make HCBASE=/c/ghc/ghc-6.4.1/bin/ config ... Skipping Main ( Setup.lhs, dist/tmp/Main.o ) Linking ... ./setup configure --ghc --prefix=/usr/local Configuring Cabal-1.1.1... configure: Using install prefix: C:/MSYS/1.0/local configure: Using compiler: c:\GHC\GHC-6.4.1\BIN\ghc.exe configure: Compiler flavor: GHC configure: Compiler version: 6.4.1 configure: Using package tool: c:\GHC\GHC-6.4.1\BIN\ghc-pkg.exe configure: No haddock found configure: No happy found configure: No alex found configure: Using hsc2hs: c:\GHC\GHC-6.4.1\BIN\hsc2hs.exe configure: No c2hs found configure: No cpphs found configure: No greencard found configure: Dependency base-any: using base-1.0 configure: Dependency util-any: using util-1.0 Yay! Now to install it: $ make HCBASE=/c/ghc/ghc-6.4.1/bin/ install ... Installing: C:/MSYS/1.0/local\Haskell\Cabal-1.1.1\ghc-6.4.1 & C:/MSYS/1.0/local\Cabal-1.1.1\bin Cabal-1.1.1... Registering Cabal-1.1.1... Ok, it all seems fine. Now to try to use it: $ cd tests/HSQL $ runghc Setup.lhs configure ghc.exe: unable to load package `Cabal-1.1.1' <interactive>: C:/MSYS/1.0/local\Haskell\Cabal-1.1.1\ghc-6.4.1/HSCabal-1.1.1.o: unknown symbol `_SHGetFolderPathA' Bummer. We need to link with SHFOLDER.DLL. So, we change Cabal's cabal file (similarly to the comment that was in CVS recently): $ cd ../.. $ diff -u ../cabal-1.1.1.orig/Cabal.cabal Cabal.cabal --- ../cabal-1.1.1.orig/Cabal.cabal Sat Aug 6 11:50:00 2005 +++ Cabal.cabal Sat Aug 6 12:17:46 2005 @@ -48,6 +48,7 @@ Distribution.Compat.Exception, Distribution.Compat.RawSystem Extensions: CPP +Extra-Libraries: shfolder executable: cabal-setup main-is: DefaultSetup.lhs Then, install again and try the test again: $ make HCBASE=/c/ghc/ghc-6.4.1/bin/ install ... Registering Cabal-1.1.1... $ cd tests/HSQL/ $ runghc Setup.lhs configure -=-= Cabal executing: ./configure =-=- Bad command or file name Configure Succeeded. Triple yay! Using this version I have successfully installed the real HSQL. How, it seems wrong to have to specify the A or W version explicitly because there is a #define for it that depends on whther UNICODE is defined. I don't know why that's not being picked up (it's in shldobj.h and I see that that's been specified in CVS, but adding it makes no difference for me.) The patch follows:

On 8/6/05, Toby Allsopp
How, it seems wrong to have to specify the A or W version explicitly because there is a #define for it that depends on whther UNICODE is defined. I don't know why that's not being picked up (it's in shldobj.h and I see that that's been specified in CVS, but adding it makes no difference for me.)
When the Haskell code is compiled via gcc then the compiler will automatically select A or W version but the native code generator in GHC doesn't know anything about all these defines in shldobj.h. Cheers, Krasimir

I think the right way is to use postConf hook in the Cabal's
Setup.lhs. The hook should check whether the BUILD platform is Windows
98 and it can add shfolder to extra-libs field in the hooked build
info. Currently I am not sure how to check whether the platform is
Windows 98. After all the Setup.lhs should still run under Unix. I
wonder how many people still use Windows 98 platform. In my opinion it
is too unstable.
Cheers,
Krasimir
On 8/8/05, Isaac Jones
I don't understand this problem. What is the right way to fix this in cabal?

On Tue, Aug 09, 2005 at 10:22:52AM +0300, Krasimir Angelov wrote:
I think the right way is to use postConf hook in the Cabal's Setup.lhs. The hook should check whether the BUILD platform is Windows 98 and it can add shfolder to extra-libs field in the hooked build info. Currently I am not sure how to check whether the platform is Windows 98. After all the Setup.lhs should still run under Unix. I wonder how many people still use Windows 98 platform. In my opinion it is too unstable.
That won't work for building a portable MSI, though. And shfolder is also needed under NT4, I believe.

Krasimir Angelov
I think the right way is to use postConf hook in the Cabal's Setup.lhs. The hook should check whether the BUILD platform is Windows 98 and it can add shfolder to extra-libs field in the hooked build info. Currently I am not sure how to check whether the platform is Windows 98. After all the Setup.lhs should still run under Unix. I wonder how many people still use Windows 98 platform. In my opinion it is too unstable.
As far as I know, it's safe to link to shfolder on all versions of Windows, so the test for Windows 98 specifically should be unnecessary. Only Windows generally needs to be tested for. I see that something like this has been done in package.conf.in, but I don't see what that file is used for. As for supporting Windows 98 at all, I wouldn't hold it against you if ou just didn't bother. I certainly wouldn't bother if I had a more recent version to use or if I could persuade my customer (AKA my wife) to use Linux. It would make my life a little easier of it just worked out of the box though :-) Regards, Toby.

Krasimir Angelov
On 8/6/05, Toby Allsopp
wrote: How, it seems wrong to have to specify the A or W version explicitly because there is a #define for it that depends on whther UNICODE is defined. I don't know why that's not being picked up (it's in shldobj.h and I see that that's been specified in CVS, but adding it makes no difference for me.)
When the Haskell code is compiled via gcc then the compiler will automatically select A or W version but the native code generator in GHC doesn't know anything about all these defines in shldobj.h.
Ah, that kind of makes sense. And, indeed, adding -fvia-C to the GHC options in GNUmakefile allows it to build setup using "shlobj.h SHGetFolderPath". However, it still doesn't work when running "./setup build", even when I added a line "ghc-options: -fvia-C" to Cabal.cabal. What I don't understand is how this is building for other people on Windows. Toby.
participants (4)
-
Isaac Jones
-
Krasimir Angelov
-
Ross Paterson
-
Toby Allsopp