How to build QT4 projects in console

All you need is to have all code files in a single folder, nothing else. No .pro files, no Makefiles, nothing. Then you execute these commands in this order:

  1. qmake -project (creates foldername.pro file)
  2. Edit .pro file if necessary.
  3. qmake foldername.pro (creates Makefile)
  4. make

You might need to add stuff to .pro file if the application you are trying to build uses some of the Qt modules that are not included by default (only core and gui are included by default). You do this by inserting one or more of the following lines in .pro file:


QT += network
QT += xml
QT += webkit
QT += network
QT += opengl
QT += sql
... and others ...

If the application needs to link some other library to the project, you have to state that explicitly in the .pro file in following matter:


LIBS += -lvlc
LIBS += -lpqxx


Previous: pqxx::undefined_table and pqxx::undefined_column
Next: Easy reference for implementing signal and slot