QApplication: Nosuchfileordirectory-General Linux technology-Linux programming and kernel information for typical Qt errors. for details, see the following. QApplication: No such file or directory
This error message is generally the first example of Qt Programming when a newbie builds Qt4's first application "Hello, World. It is easy to say.
# Include
# Include
Int main (int argc, char * argv [])
{
QApplication app (argc, argv );
QWidget * ww = new QWidget ();
Ww-> resize( 300,200 );
Ww-> show ();
Return app.exe c ();
}
The above error occurs in the compilation result, which is called depressing.
As a matter of fact, the new user can solve the problem by himself. According to the prompt QApplication, the header file cannot be found. Then we can check the environment variable INCPATH in the Makefile in the current directory to know where the make application is going to find the header file. For example
./Makefile partial content
15 CXXFLAGS =-pipe-O2-Wall-W-D_REENTRANT $ (DEFINES)
16 INCPATH =-I/usr/share/qt4/mkspecs/linux-g ++-I. -I/usr/include/qt4/QtCore-I/usr/include/qt4/QtGui-I/usr/include/qt4-I. -I. -I.
17 LINK = g ++
Check whether the file/usr/include/qt4/QtGui/QApplication exists in the row 16th. (if the file does not exist, no error will occur ). There are roughly two reasons why the QApplication file does not exist.
1) no Qt4 development kit is installed.
Solution to wrap the development, for example, ubuntu is to execute sudo install libqt4-dev in shell; Fedora/SUSe is to execute sudo yum install qt4-devel in shell
2) Qt4 is developed and packaged, but qmake of Qt3 is called.
Some systems have both Qt3 and Qt4 installed. If qmake of qt3 is called, the header file path in INCPATH in the header also points to Qt3, so the file QApplication cannot be found. The corresponding solution is to call qmake in the Qt4 installation path to generate Makefile. it is best to use the full path. Qmake installation path in Qt4 is
Zhu @ ubuntu :~ /Test/widget $ dpkg-L qt4-qmake | grep qmake | grep bin
/Usr/bin/qmake-qt4
/Usr/share/qt4/bin/qmake
Therefore, you only need to execute
/Usr/bin/qmake-qt4; make OR/usr/share/qt4/bin/qmake: make
Qt4 files can be used to compile this simplest Qt4 application.
All posts on this site are reserved by this site and the original author. This article can only be reproduced if the copyright information, original article links, and original article authors are retained. do not delete or modify the original article content for reprinting, it is not intended for commercial purposes. Thank you for your cooperation.
Http://www.cuteqt.com/blog? P = 307
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.