Sunday, July 4, 2010

Compile cpp code using qmake in command line

Create the source code helloqt.cpp, in folder ~/QtPrj/helloqt

#include <QApplication>
#include <QtGui>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello World Qt!");
label->show();
return app.exec();
}


Start a Terminal, type the commands:

$qmake -project

$qmake helloqt.pro

$make

and Run the output file:

$./helloqt