Compiling and Generating helloworld
Procedure
- Use PuTTY to log in to the server as the root user.
- Create a helloworld directory.
mkdir helloworld
- Go to the helloworld directory.
cd helloworld
- Create a helloworld.cpp file and edit it.
- Create and open the helloworld.cpp file.
vi helloworld.cpp
- Press i to enter insert mode and add the following information:
#include<QApplication> #include<QLabel> int main(int argc,char *argv[]) { QApplication app(argc,argv); QLabel *label=new QLabel("helloworld!"); label->show(); return app.exec(); } - Press Esc, type :wq!, and press Enter to save the file and exit.
- Create and open the helloworld.cpp file.
- Perform the compilation.
qmake -project qmake make
If the following error information is displayed after running the make command, add QT+=widgets to the end of the helloworld.pro file.

helloworld.pro is the a.pro file generated by running the qmake -project command. a indicates the directory name.
- Run helloworld.
./helloworld

Parent topic: Running and Verification