Error "Qapplication:no such file or directory" when running program in QT

Source: Internet
Author: User

In the root directory, create a folder named Hello, under which a hello.cpp file is created with the following contents:

#include <QApplication> #include <qlabel>int main (int argc, char **argv) {qapplication  A (argc, argv); Qlabel MyLabel ("Hello the World"); Mylabel.show (); return a.exec ();}

Run the following command under the file:

Qmake-project

This command generates a Hello.pro project file

Qmake

This command generates a makefile file

Make

This command is used to generate the target file: hello,hello.o file

However, you encounter an error in this process:


g++-c-pipe-o2-wall-w-d_reentrant-dqt_no_debug-dqt_gui_lib-dqt_core_lib-i/usr/share/qt4/mkspecs/linux-g++-I.-I/ Usr/include/qt4/qtcore-i/usr/include/qt4/qtgui-i/usr/include/qt4-i.-I.-O hello.o hello.cpp
Hello.cpp:1:24:fatal error:QApplication:No such file or directory
#include <QApplication>
^
Compilation terminated.
Make: * * * [hello.o] Error 1

Cause: No development package for QT4 installed

Solution:

Put the development package on, use the following command under Ubuntu: sudo apt-get install Libqt4-dev

Run the make command now to generate the hello,hello.o file.

Run the./hello command in this directory to run the generated program.



Error "Qapplication:no such file or directory" when running program in QT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.