Why does Qt use its own make tool, qmake?

24,815

Solution 1

Qt uses qmake to transparently support Qt's various addons, including "moc, the meta-object compiler" (which provides signals & slots), "uic, the ui compiler" (which creates header files from .ui designer files), "rcc, the resource compiler" (which compiles resources).

There's nothing to stop you using any build system you want. however, it's a lot more work. For example, you need to run "moc" over every header file that contains a class that has signals or slots. In general it's not recommended, especially for someone who's just starting to use Qt.

QMake does not call g++/gcc directly. Instead, qmake creates native make files on your current platform. Under linux it creates standard GNU make files, under windows it can generate visual studio make files, under Mac OS X it can generate XCode project files. You then invoke your native build system (either GNU make, or MS NMake, or xcodebuild or whatever), which will call your native compiler (g++/gcc or whatever).

Solution 2

In my opinnion qmake is cool for simple projects (you can just qmake -project; qmake; make), but horrible and not documented enough for largish projects. Especially the configure functionality of qmake is a joke.

The best build systems I know are CMake and Waf (Python -based). In my own Qt-projects I use CMake to do the job. Just like KDE-guys :)

Solution 3

To support its signal/slot system Qt relies on a special preprocessor and compiler that generates intermediate objects that do much of the processing. They refer to this as the Meta-Object Compiler or MOC.

See Qt 5 Documentation: Using the Meta-Object Compiler for details.

The MOC (along with a couple of other intermediate tools) works in conjunction with qmake; a build automation tool which produces Makefiles in your native format (VC++, g++, etc.) that build the intermediate files generated by the MOC as well as all of your source files into the final executable.

Solution 4

qmake is designed to be cross platform and flexible. It can compatible with Microsoft Visual Studio and Xcode.

You can find it all in the qmake Manual.

qmake generates a Makefile based on the information in a project file. Project files are created by the developer, and are usually simple, but more sophisticated project files can be created for complex projects. qmake contains additional features to support development with Qt, automatically including build rules for moc and uic. qmake can also generate projects for Microsoft Visual studio without requiring the developer to change the project file.

Solution 5

In order

a) because it does lot behind the scenes for you

b) yes, see a)

c) yes, it does call g++ (but can support other compilers if you have them)

Share:
24,815
Trevor Boyd Smith
Author by

Trevor Boyd Smith

http://www.linkedin.com/in/trevorboydsmith

Updated on June 13, 2020

Comments

  • Trevor Boyd Smith
    Trevor Boyd Smith almost 4 years

    I just started using Qt and noticed that it uses its own make tool, qmake.

    • Why does Qt use its own make tool?
    • Is there something special that prevents it from using a standard make tool?
    • Does qmake call the GCC C++ compiler?