Thursday, April 22, 2010

The sorry plight of a Windows programmer (aka me)

Having secured fame and fortune with MazesOfMonad, my console based RPG, and having some ideas for some games that would look even better with a graphical front end, I decided it was time to take the bulls by the horn and go seriously into Haskell GUI programming. Well, the bull won and I feel truly gored...
So what's wrong? Well, after fooling around on my Windows 7 computer for a few nights I've achieved nothing. I now have three different copies of MinGW installed in different places. I have tried to installed SDL, GTK2HS, WXWidgets and Happstack and I have failed at all of them. I know WXWidgets is manageable because I've done it before, I only seem to have some include paths issues. libSDL itself installed but not the Haskell bindings. I found somebody with the same problem on the web, that then told me he had given up. I even managed to get Darcs errors with Gtk2Hs. In despair I thought I could develop a web based game but even the darcs version of happstack failed to compile, I remembered then some bug mentioned on the mailing list, so I should probably just download the latest stable version instead of the development branch.
Some problems are down to some silly things I did. For example installing the Haskell Platform in a directory with spaces is not a great idea (I don't remember if it was the default), because then a lot of paths referencing its MinGW install are wrong in the MSYS shell...
But most are due to the Unixy nature of a lot of the GUI components. Now I see a configure script and my blood freezes. I run "cabal install foo" and I get the dreaded message "this package has a configure script, you need to dive into Unix hell". Can you tell me why I have three versions of GCC, and two make a configure script crash with "c compiler cannot create executables" and the third one works? Where can I download one single file that will allow me to have a full MSYS/MinGW setup with most of what I need? I'm sure there are solutions to a lot of the problems I have, and maybe I need to spend more time reading the INSTALL files and such, and download everything from the MinGW files page. But why can't it Just Work? I mean, I work with Java at work, we do GUI work in SWT now and before that in Swing, we use a lot of libraries, and we never run into any installation problem. Maybe once or twice over the past couple of years we had a cross-platform compatibility issue or a library conflict. I know, I know, apples and oranges, but I'm now thinking that writing my own lazy, purely functional language with monads on top of the JVM with Java integration is going to be easier than getting a GUI library with Haskell bindings to work.
I like to write applications, not spend my free time trying to get libraries to install.

13 comments:

Luke Palmer said...

I have successfully used GLUT and glfw-b on Windows. Unfortunately, GLUT in all its uglitude is the only OpenGL interface that works on Windows, Mac, and Linux.

Unknown said...

It took a turn for the worse with Vista. But the problem will remain as long as there are unix libraries that are hard to port / install. Even such a basic tool as curl is a real hassle to install, at least the last time I tried it.

So yes, I do blame Microsoft for not having a decent shell and a standardized way to install libs and include files.

snk_kid said...

It use to be a lot worse than it currently is, you can get all SDL packages (ttf,image,etc) built and working on windows with just a little bit of effort, it shouldn't be this way of-course compared to using package managers and cabal install on linux distributions but the problem is GCC/*nix philosophy on a windows system doesn't just gel as well.

Eric Parnell said...

You have my sympathy. I am on Windows 7 and tried to use Haskell with GLUT. I never got it to work -- getting the types of errors you mention. In my case, I believe the problems were FFI-related; I could never get a working version of the Haskell bindings and GLUT to work.

Unknown said...

I recently ported the [very basic shell of a] game I'm working on to Windows 7. SDL can in fact be installed, but it takes manual work. Cabal-install will not cut it.

You can check my post about the steps required to install SDL and some auxiliary libraries here.

At least for SDL, you do not need to install any more copies of MinGW, other than what comes with the Haskell Platform install. Nor do you need MSYS. Using runhaskell in a command line works alright.

Good luck. Right now, hacking haskell on Windows is definitely the path of pain.

Unknown said...

I've had similar woes. My "solution" was to run Ubuntu under VirtualBox and scrap any hopes of developing GUI apps. directly through Windows.

Unknown said...

The packaged gtk2hs installers worked for me, once I got a slightly older platform release that had the right GHC version.

Anonymous said...

Hi,

Have you tried to use qtHaskell ?

I was also thinking to use Gtk2Hs & wxHaskell as Haskell GUI libs, but finally settled on Qt.


Sincerely,
Gour

rtperson said...

I have used GLUT on Windows, but getting it to work has been a crap shoot every time. Good to know I'm not the only one who has issues.

There was an email exchange on Haskell-Cafe about a year ago between Duncan Coutts and Sven Panne about issues with OpenGL under Windows, but I haven't seen anything come of it. Sven's an amazing contributor -- essentially a one-man OpenGL contribution machine, but he simply doesn't have the resources to maintain installation scripts for every platform.

Unknown said...

I have seen the SDL bindings work on Windows, Mac, and Linux (with tweaking required for some).

Unknown said...

I think a lot of people in our community feel like windows support is not important, and are frustrated when they do try to support libraries there. There doesn't seem to be an accepted way of ensuring support for windows.
It's come a good way just recently with the haskell platform, which made it very easy to get a complete haskell environment up. But it's got a ways to go before it's equally comfortable on all platforms. For now, too many important libraries are very hard to install in windows. I'm not sure it necessarily has to be this way. Nor am I saying we should cater to windows. I think we could factor a out lot of the cross-platform hassle with better tools. It would make the work of library developers easier. At the same time, it would attract a lot of new users which before would have taken one look at a cabal install error message and given up.
Heh, it occurs to me that perhaps haskell's motto of "avoid success at all costs" just might reflect a desire in part to avoid having to deal with these kinds of people. But I'm sure it wouldn't hurt things so bad. After all, they'd still have to dedicate themselves to learning monads.

BMeph said...

I feel ya dog - I've a 64-bit Vista machine at home. I STILL have yet to see a stable MinGW release for 64-bit machines. 64-bit Linux works great - I've seen lambdabot run for weeks on it. Unfortunately, 64-bit MinGW doesn't have a tenth of the talent working on it as does GHC.

Ah well, maybe it's time to look at VBox...

John Creighton said...

Surely your last point is an exaggeration. I've tried once to get msys to work for gtkhs and found that there wasn't a good distribution that had all the files you need. You had to search though several zip files to find what you want. So I gave up.

Anyway, there are already functional languages for java (closure, scala, jaskel) The first to are well supported and used a lot. There is also a foreign function interface for Haskell. Perhaps building a Haskell binding for swing might more portable then other solutions.

However, I may give the msys another shot one of these days.