Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling and Generating helloworld

Procedure

  1. Use PuTTY to log in to the server as the root user.
  2. Create a helloworld directory.
    mkdir helloworld
  3. Go to the helloworld directory.
    cd helloworld
  4. Create a helloworld.cpp file and edit it.
    1. Create and open the helloworld.cpp file.
      vi helloworld.cpp
    2. 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();
       }
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  5. 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.

  6. Run helloworld.
    ./helloworld