Compiling a windows application as supposed a console application from haskell

The fact that my haskell application always runs in a command window(Windows land here) was really nagging me. I happened to be fiddling with C# express studio last night, and found out that the difference between a "console application" (one what always invokes a command window to run itself) and a "windows application" is but a compiler flag. So I thought, there must be an analogous thing in haskell, but first in gcc. I hunted down this gcc flag, and it turned out to be -mwindows. For compiling haskell using ghc, you'd use -optl-mwindows. This compiled at first, but didn't run, because it turns out that any time you try to print something to the console, it bombs out - this is the case for haskell only, for c, it just simply doesn't print anything on the screen. So I had to write a quiet version of my program that doesn't make use the putStr functions - err, actions - at all. Luckily this wasn't very hard because I had already separated out all my lib stuff that doesn't do any console IO to a separate file. Once that was done, it all worked. So now every time the scheduler runs my backup program there won't be an annoying window popping up. This is great!

blog comments powered by Disqus