Building Qt applications with GNU Autotools / without QMake
News: 2007-06-14 Autotroll 0.2 released
2008-12-09 A Git repository for Autotroll is available.
AutoTroll is very easy to use: it's a simple M4 file and piece of Makefile
you need to include in your project. You invoke the magic macro AT_WITH_QT
in your configure.ac, and that's all, you're done: you can now
use new flags in your Makefiles to build your applications.
AutoTroll is released under the GPL with an exception to be used in
non-GPL compatible projects.
NEW! AutoTroll's sources are now available in a Git repository:
git clone git://repo.or.cz/autotroll.git
You can download a sample project that uses Qt's example with AutoTroll:
MD5 (autotroll-demo-0.2.tar.gz) = b42e44847a3fd8259ab594cedfc1d053
Several reasons why you might want to use AutoTroll:
* Because QMake doesn't give as much power as Autoconf/Automake/Libtool.
* Because your project already uses the GNU Autotools.
* Because you are tired of make clean all just because qmake does not
properly handle dependencies.
The GNU Autotools give you and your users much more power than qmake can:
* You can easily make your package configurable through the configure
script (eg: your program depends on a library, say boost, and your
user has installed it under a non-standard prefix: they can just run:
* Your package can run sanity tests (through configure) before actually
letting the user try compile it and get cryptic compilation errors.
* These tests are much more reliable than the pre-computed grid of
platforms and compilers of qmake.
* The maintainers enjoy the benefits of the features provided by the
Autotools (libtool, make distcheck, easy support of nested packages, etc.)
* The packagers enjoy the benefits of the features provided by the
Autotools (easily configurable setup, nice features such as DESTDIR
installs for easy sandboxing and binary distributions)
* The power users enjoy the benefits of the features provided by the
Autotools (They can easily change the location where the package will be
installed by changing the prefix, use their config.site, tweak the
compilation flags at configure or make time, use VPATH builds, use
install-exec / install-data to maintain installations on NFS shares, and
AutoTroll has been tested successfully with Qt 4.0+, Qt 4.1+, Qt 4.2+ and Qt
4.3+ on Linux (Ubuntu, Debian, Gentoo) and Windows XP (Cygwin, MinGW) and
Mac OSX (XCode). Qt 3 might be supported but hasn't been tested enough.
How does it work?
It's very simple: AutoTroll simply creates a fake Qt project at configure
time, calls qmake and analyses the Makefile produced by qmake to deduce the
various compilation FLAGS needed to build a Qt application. It's as simple as
that and has the advantage of being portable on all plateforms where qmake
works (instead of hardcoding some flags -- usually for Windows and Linux only
-- which is what most other people do to integrate Qt stuff in an
On Windows, AutoTroll is not enough if you plan to use Cygwin or MinGW. QMake
will generate paths such as C:\Qt\bin\moc.exe and the shells will usually
understand the command 'C:Qtbinmoc.exe' because the backslash did not actually
It is true that MinGW shell helps a lot with this kind of issue but MinGW
does not always do all the translations needed and you will most likely run
into troubles. Moreover, you might want to use a Cygwin shell instead simply
because Cygwin offers more features and packages than MinGW.
For all these reasons, I had to develop all sorts of wrappers in order to be
able to transparently build UNIX projects on Windows.
<< Back to TsunaNET.net