Saturday 8 November 2008

On Clojure - part 2 - Distributing QtJambi with Clojure.

One of the questions I've seen coming up a few times is how to distribute clojure programs. The obvious answer is to build executable JAR files.


I while ago I produced a simple database application for my girlfriends recruitment business, NRecruit. I developed this using Clojure on my Arch Linux based laptop, and deployed to her MacBook running OS X Leopard. The underlying database is sqlite3, but it could just as well be MySQL or anything else that is supported by JDBC. For simplicity I unzip the required JAR files in the root directory of the project and then rebundle them into a single distributable JAR following this guide.


That application is in production use right now, but there have been a number of problems with the Swing based GUI. I have been trying to address them, but I find Swing an unnecessarily painful toolkit to use.


Several years back (circa KDE 2, and early KDE 3) I used to do some development with Qt in C++ and Ruby. I have looked at Qt4 a couple of time before and I still feel that Qt is one of the nicest GUI toolkits out there. So I read this blog entry on using Qt4 with clojure with great excitement I started porting the NRecruit database UI over to Qt.


So far I've hit two issues. The first one (using Qt Designer files from within Clojure) I'll address in a later post; the second one is more fundemental. Distributing QtJambi in your jar has a few gotchas. The most succesful approach I've found is this:



  • unzip the qtjambi-4.4.3_01.jar and qtjambi-linux32-gcc-4.4.3_01.jar files in your projects root directory (where the version number and platform name vary based on the version of QtJambi you're using and the platform you're targetting).

  • When you make your jar file make sure you include the "com" and "lib" directories and the file "qtjambi-deployment.xml"


That leaves me with what I'd describe as a "statically linked" executable (it isn't in any sense statically linked, but the effect is the same).


More later...


No comments: