AUG
6
2006

Intro to KDE/Qt build systems for new developers

In the recent KDevelop dot interview I noticed a very astute comment by someone named borker:

"One of the things I've loved about picking up Qt/KDE was how quickly you can make non-trivial applications, but I found learning Qt/KDE was a weird reverse... rather than writing code first and then learning the complexities of the build process later, as required, I found myself needing to come up to speed with the build process first and then write code. Not being overly familiar with the GNU tool chain didn't help speed up this process either. I found it to be a frustrating blocker to actually writing code and it wasn't helped by most of the available tutorials being great on coding advice but very slim on build advice, so when I wanted to go from 'hello world' to something a bit more 'real world' I ran smack into the build system and all my momentum died completely. Anything that could help a beginner like me out in the way of teach as you go type stuff would be great." -- link

I can't tell you how many times I've seen someone new to KDE/Qt development come into the #kdevelop channel after being absolutely floored by Autohell. Well, as you might have heard, KDE is going to be moving away from Autotools, so hopefully that will help. Here is a short introduction to all the build systems you might encounter in KDE land.

  1. QMake Version 3 -- Used by Qt 3.x applications.
    Brain dead easy to learn.

  2. QMake Version 4 -- Used by Qt 4.x applications.
    Brain dead easy to learn.

  3. CMake -- Used by KDE 4.x and Qt 4.x applications.
    Fairly easy to learn, but more powerful.

  4. Autotools -- Used by KDE 3.x applications.
    This will make your eyes bleed and your brain beg for mercy.

  5. Scons -- Previously considered for KDE 4.x applications, but ultimately dropped for KDE/Qt development.

If you are a new developer and have no previous experience with KDE/Qt then learn #2 first. You need to learn how to use Qt 4 and this will be the most pain free way to do so. Once you've done that, then you can venture into KDE 4 land and learn how to use #3. It is not that hard and your experience with QMake 4 will probably help.

If you are familiar with Qt and how to use it, but you are thinking that you want to develop KDE 4 applications, then by all means start with #3.

Unless you are currently hacking on KDE 3 or have knowledge of Autotools, you have no reason to suffer through #4 especially if you are new to KDE/Qt development. Save your energy and learn QMake 4 first and then CMake.

If you like scons, great! But, please keep in mind that most KDE applications will be using CMake.

Comments

I have a few prf files that should work for KDE 4 development. There is no reason anyone should need to bother with CMake for doing 3rd party KDE development. 99.9% of what you need can now be done with QMake / package-conf and a few custom prf files. I have not looked at dbus, but in theory since Qt 4.2 has support for it, that should be a freebie. I think the big missing parts deal with documentation and translation targets. KConfigXT seems to work for samples, but I never figured out how to make that usable in KDE 3, so I am not 100% sure it really works.

Sample KDE QMake project that will work for 99% of your apps:

TEMPLATE = app
CONFIG += kde debug warn_on

SOURCES += main.cpp mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui


By Ian Reinhart Geiser at Sun, 08/06/2006 - 18:43

Maybe this is obvious for you KDE/Qt guru's but how can you develop for KDE 4 if it's out yet? It would seem to me that it makes testing a bit more difficult than it should be ;-)

(Yes, there is KDE 4 code and it in some compilable state but this article was for beginners which should mean that is has to be dead easy to get started, shouldn't it?)


By quintesse at Sun, 08/06/2006 - 20:21

But you can still develop apps against it. Just use anonymous SVN.

But, read closely and you'll see that isn't what I suggest. For beginners the best method is to learn Qt 4 and thereby use QMake 4. See?

However, if you are not a beginner or you already no Qt 4, then by all means check out KDE 4 in anonymous SVN.


By Adam Treat at Sun, 08/06/2006 - 21:16

Programming against Qt4 and kde4 is something you can do in kde3, or even fluxbox if you like. The trick is to use the proper libraries. So you can program your cool new kde4 app by checking out the kdelibs module from svn and compiling that. Some kdebase apps are nice to have installed. Like the kdebugdialog or the kcrash dialog. But not essential.

Cheers!


By Thomas Zander at Sun, 08/06/2006 - 21:29