Side effects ...of deploying application to Windows
Yesterday I wanted to test HeyTrack (which will be hopefully released this weekend) on Windows to make sure there are no serious bugs which will put me in shame. But, in the end, the fact that HeyTrack runs on Windows is only a side effect. The result is many fixed bugs, but none of them was in HeyTrack.
First, rather easy problem, was crosscompiling QJSON with mingw32. Done in a few minutes. Then there was some problem with crosscompiling toolchain for CMake. In comparison to later problems it was easy too. Then things got worse.
The application failed to initialize properly (0xc0000005)
When I finally compiled HeyTrack, solved the DLL-hell and no errors about missing DLL popped out, another messagebox welcomed me:

First thing what came to mind was to download Windows version of GDB and get some backtrace. After solving another DLL-hell and running the errorbox through GDB, I was greeted by two words:
No stack.
Time to UTFG. ... It's a known issue in mingw32-gcc 4.5.0. I resisted the temptation to downgrade back to good ol' GCC 4.4 and after few hours solved it. The final solution was to update mingw32-binutils to version 2.20.51, recompile compiler (and everything another like recently built mingw32-qjson) ... and hope.
NSIS - the best and the worst at the same time
HeyTrack compiled, ran successfully, but average Windows user would really like to read a few pages of EULA and repeatedly click on Next. Time to make an installer.
NSIS is the best open-source installer solution but also the worst, because there is nothing comparable or even better. 64bit support was hacked in not so long ago and its scripting language (if you don't want your installer to look like in early '90s) is terrible. I had tried to script that once, but although I succeeded, I didn't want to learn that mess again. So, because I'm happy CMake user, I tried CPack.
CPack has no documentation. Yes, it's a fact, get over it. I grabbed an example somewhere and googled every variable to find out its meaning and finally came up with something that producted at least .tar.gz packages. When I ran CPack in build tree for Windows, it switched automatically to NSIS. Neat! ...but not for long. It crashed one row of output after, with this message:
terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct NULL not valid
Huh? I didn't know wheter the exception was thrown in CPack or in NSIS, running cpack -V told more, but still nothing usable. So I switched to GDB again, backtrace said in was in CPack, but I didn't know where.
... After an hour or three I finally managed to build debug version of CMake, which was amazing 250 megs in size. Running CPack through GDB again, it said the exact file and line, which was good. The surprise came after opening the file. CPack crashed while handling unexpected output from NSIS, even before it could write anything to error output. How embarassing. But CPack internals are as horrible as NSIS scripting language (or at least for that particular file) and all my attempts to fix it were unsuccessful, so I decided to fix NSIS instead.
The unexpected output was NSIS version, after running makensis -VERSION CPack expected something like v2.46, but NSIS returned v17-09-2010.cvs. Then CPack crashed while trying to save an error log. After patching NSIS (it was easier than I expected), the installer was built instantly and even worked.
Qt and Phonon
This is what I'm working on now, getting Phonon on Windows to work. Playing internet radio streams via HeyTrack is the main feature and it wouldn't be good to announce application without any working feature. As Windows don't have D-BUS, something like remote controlling VLC player is impossible, so I'm stuck with Phonon there. It works so-so in Linux, but not in Windows. I'm now trying to update mingw32-qt to version 4.6.3, it involves digging in NSIS *.exe installer and NSIS has now the ultimate chance to strike back against me :-)

