Reputation: 1393
Iam starting learning Qt. I have this code snippet and i want to know how i can compile this and excute in gcc. Platform : Linux , gcc compiler
1 #include <QtGui>
2
3 int main(int argc, char *argv[])
4 {
5 QApplication app(argc, argv);
6 QLabel label("Hello, world!");
7 label.show();
8
9 return app.exec();
10 }
Upvotes: 0
Views: 121
Reputation: 1705
That is nicely explained here: http://qt-project.org/doc/qt-4.8/gettingstartedqt.html
It basically boils down to
qmake -project
qmake
make
Also I really recommend to install and use QtCreator: http://qt-project.org/downloads
Upvotes: 2
Reputation: 10658
In your case this is quite simple since you do not have derived any windows, buttons or other widgets.
In general for producing a QT app. you need to do the following:
Compile your annotated headers to meta-object C++ code. You do this by running the meta-object compiler (MOC).
Compile both your source files as well as the source files produced by MOC.
Link all the files together with the QT libraries.
In your case you do not need step 1 and 2, so step three is enough. Just figure out where the necessary libraries reside and link those with the compiled main
.
All this is assuming you do not want to use qmake
provided with QT, which automatizes the three steps.
Upvotes: 0