views:

1379

answers:

6

I just started using Qt and noticed that it uses it's 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?

+2  A: 

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)

Dirk Eddelbuettel
+16  A: 

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).

Thomi
RE "QMake does not call g++/gcc directly": So QT doesn't use a standard C++ compiler like gcc? What compiler does it use?
Trevor Boyd Smith
QT is cross platform; it can be compiled with many different compilers.
Ron Warholic
QMake DOES NOT call gcc directly. It creates platform-specific make files that *you* then invoke. These make files in turn call whatever compiler you seem to be using.
Thomi
@Trevor, QMake simply generates makefiles and other build projects for different systems, like GNU makefiles, VC++ or XCode projects, NMake makefile, and so on.
iconiK
+4  A: 

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.

Brian Gianforcaro
=> So it's not exactly a make tool, but a pre-make tool ;)
Cecil Has a Name
+3  A: 

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 http://doc.trolltech.com/4.5/moc.html for details.

The MOC (along with a couple of other intermediate tools) works in conjunction with qmake; 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.

Ron Warholic
+1  A: 

CMake, yet another buildsystem, also has excellent support for Qt, enabling easy moc'ing and ui compiling. KDE is using CMake (hence the good Qt support). Unlike qmake, CMake "piggybacks" another buildsystem, e.g. Makefiles or Visual Studio solution files or . Scons is yet another buildsystem. This system is based on Python and is works in a manner similar to qmake in the sense that it doesn't piggyback any other buildsystem. I'm not sure how Qt support is for Scons, but I recon it should be a breeze.

larsm
QMake also "piggybacks" another buildsystem, they both generate the local build files e.g. Makefiles or Visual Studio Solution files.
Mike McQuaid
A: 

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 :)

Game Coder