Tuesday, 19 February 2008

Qt and MySQL plugin issues

Lately I've been playing with a recipe management application called krecipes. I had used the FreeBSD port in the past, but I really wanted to run it locally on various Macs that I have and have them all connect back to the central recipe database on the FreeBSD server.

And so I needed to venture into the mess that is the current Mac open-source ports/packaging system. I say "system" (singular) deliberately; I well know there are many options available in this space, but there really shouldn't be. Good operating systems tend to really only have one system that everyone uses to install and manage open-source software so that effort is not duplicated unnecessarily (which is exponential due to the thousands of applications that need to be tracked in any packaging system). Any gripes with how the current system works should be sorted out within that system and let it evolve over time rather than splitting off yet another effort to do ports/packages "a better way".

Apart from the aforementioned waste of effort by port maintainers, it's just down right confusing for users (even experienced ones). The Mac is a perfect example. It has one of the best application management systems from a end-user point of view (drag and drop to install and delete - how easy is that!) and any system that provides access to open-source software should try and be that easy as well. But if you want to tread in this space you are met with a bewildering array of options; Fink, DarwinPorts, MacPorts, RPM on MacOS X, and it wouldn't surprise me if there are others as well.

I think there may be some link between DarwinPorts and MacPorts, but quite frankly, that proves my point about how confusing it is. These sites exist, various people advise using them for different reasons, and there really isn't any definitive advice on which one you should use. The web sites for these systems are universally bad as well - there just isn't clean information on any of them about why you should use their system and what the key differences are between the systems. Unless you want to spend hours and hours researching the history of these systems you're really left in the dark. And quite frankly the whole point of these systems is to save you hours and hours and not force you to waste hours and hours.

Ok, rant finished. :) For some reason in the past I had actually installed Fink on my test Mac, so I started there. As it turns out, this is the only system which has a port for krecipes anyway... *sigh* Unfortunately, it's been setup to compile and link against an older version of Qt (3.3) that compiles as multi-threaded (good), but the sub-port for the MySQL plugin compiles as single-threaded (bad). So krecipes doesn't work and spits out the following error message as expected:

Conflict in /sw/lib/qt3/plugins/sqldrivers/libqsqlmysql.so:
Plugin uses single threaded Qt library!


After no response from the port maintainer in 1-2 months (what a surprise) I decided if I had time I would wade into the mess to see if I could hack it to make it work. Just as a side note, I noted that DarwinPorts had an up to date Qt port and MySQL driver, but no krecipes port - see my note above about wasted effort.

Anyway, I found that the plugin needs

CONFIG += thread

when it's compiled. So I extracted the Qt source back into /sw/lib/qt3/src with the aim of just compiling the driver again and over-writing the one that was installed by the port. Compiling was relatively easy once instructions were found, the thread directive from above added, and some questionable advice was also found on how to get rid of a compile error I was getting about the "sql" module not being available. :)

It sounds so easy, but you have no idea how long it took to work all this out. Good news is that krecipes now works locally for me, but the bad news is that I now have to remember this custom hack as the next upgrade of Qt-MySQL driver within Fink is probably going to break things all over again.

Please send me a link if anyone has found a good page that summarises and reviews the current Mac ports and packaging systems...

No comments: