QApplication: No such file or directory
Today I have installed Qt 4.3.1 (open source) on my windows XP computer. I was trying to compile my first program "hello world" but I am getting the following errors:
hello.cpp:1:24: QApplication: No such file or directory
hello.cpp:2:23: QPushButton: No such file or directory
hello.cpp: In function `int main(int, char**)':
hello.cpp:6: error: `QApplication' undeclared (first use this function)
hello.cpp:6: error: (Each undeclared identifier is reported only once for each f
unction it appears in.)
hello.cpp:6: error: expected `;' before "app"
hello.cpp:8: error: `QPushButton' undeclared (first use this function)
hello.cpp:8: error: expected `;' before "hello"
hello.cpp:9: error: `hello' undeclared (first use this function)
hello.cpp:12: error: `app' undeclared (first use this function)
hello.cpp:13:2: warning: no newline at end of file
mingw32-make: *** [hello] Error 1
I have tried the CONFIG += qt but the problem remains..
I have the latest mingw (5.1.3) installed. I don't know what to do. I have tried almost everything I found in the web but..
Please help me to step into the fascinating Qt world!
Thank's in advance,
Panos
Re: QApplication: No such file or directory
Are you using qmake? What does the compiler command look like?
Re: QApplication: No such file or directory
I am using the following commands:
>qmake -project
>qmake hello.pro
>make hello
Re: QApplication: No such file or directory
And what does the compiler command look like (the command starting with "g++", before you get the error message)? Perhaps you should try with the version of MinGW downloaded by the Qt installer.
Re: QApplication: No such file or directory
This is the exact output:
C:\Qt\4.3.1\chap01\hello>make hello
g++ hello.cpp -o hello
hello.cpp:1:24: QApplication: No such file or directory
hello.cpp:2:23: QPushButton: No such file or directory
hello.cpp: In function `int main(int, char**)':
hello.cpp:6: error: `QApplication' undeclared (first use this function)
hello.cpp:6: error: (Each undeclared identifier is reported only once for each f
unction it appears in.)
hello.cpp:6: error: expected `;' before "app"
hello.cpp:8: error: `QPushButton' undeclared (first use this function)
hello.cpp:8: error: expected `;' before "hello"
hello.cpp:9: error: `hello' undeclared (first use this function)
hello.cpp:12: error: `app' undeclared (first use this function)
hello.cpp:13:2: warning: no newline at end of file
mingw32-make: *** [hello] Error 1
I have tried also the mingw version downloaded by the Qt installer. The result is the same. I think something is wrong with the settings and the compiler can't see the include files.
Maybe something with the configuration, but I can't find what's wrong..
Re: QApplication: No such file or directory
I think jpn asked you for the g++ command called by make. What parameters are passed to it? Especially look at the include paths. The must contain %QTDIR%/include
And make sure QTDIR is defined properly.
Re: QApplication: No such file or directory
Ah, I think I found the problem. Try plain "make" instead of "make hello".
Re: QApplication: No such file or directory
Unfortunately the problem remains..
Neither "make" worked nor the efforts looking for the QTDIR (everything seems OK).
This is the output using only "make"
C:\Qt\4.3.1\chap01\hello>make
mingw32-make -f Makefile.Debug all
mingw32-make[1]: Entering directory `C:/Qt/4.3.1/chap01/hello'
g++ -c -g -g -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL
-DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"C:/Qt/4.3.1/
include/QtCore" -I"C:/Qt/4.3.1/include/QtGui" -I"C:/Qt/4.3.1/include" -I"." -I"C
:/Qt/4.3.1/include/ActiveQt" -I"tmp\moc\debug_shared" -I"." -I"C:/Qt/4.3.1/mkspe
cs/win32-g++" -o tmp\obj\debug_shared\hello.o hello.cpp
hello.cpp:13:6: warning: no newline at end of file
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runt
ime-pseudo-reloc -Wl,-subsystem,windows -o "debug\hello.exe" tmp\obj\debug_share
d\hello.o -L"C:\Qt\4.3.1\lib" -L"C:\Qt\4.3.1\lib" -lmingw32 -lqtmaind -lQtGuid4
-lQtCored4
mingw32-make[1]: Leaving directory `C:/Qt/4.3.1/chap01/hello'
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory `C:/Qt/4.3.1/chap01/hello'
g++ -c -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_D
LL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
-I"C:/Qt/4.3.1/include/QtCore" -I"C:/Qt/4.3.1/include/QtGui" -I"C:/Qt/4.3.1/inc
lude" -I"." -I"C:/Qt/4.3.1/include/ActiveQt" -I"tmp\moc\release_shared" -I"." -I
"C:/Qt/4.3.1/mkspecs/win32-g++" -o tmp\obj\release_shared\hello.o hello.cpp
hello.cpp:13:6: warning: no newline at end of file
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runt
ime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows -o "release\hello.exe" tmp
\obj\release_shared\hello.o -L"C:\Qt\4.3.1\lib" -L"C:\Qt\4.3.1\lib" -lmingw32 -
lqtmain -lQtGui4 -lQtCore4
mingw32-make[1]: Leaving directory `C:/Qt/4.3.1/chap01/hello'
If you could understand something that I can't from the above please inform me.
Or
I would appreciate it if you could to tell me exactly what to do after installing Qt on windows XP (until the hello compilation) because I think the problem is in the configuration process. What about the environment variables, the configure.exe, the .pro file (do I need to put CONFIG += qt and where), etc.
Thank's
Re: QApplication: No such file or directory
It seems that you are using the debug libraries for the release target...
Why is that?
How does your .pro file looks?
BTW: I should have mentioned that QT opensource for Windows does not install the debug libraries also. You have to compile them.
So, it is odd, because you seem to have them.
Regards
Re: QApplication: No such file or directory
Quote:
Originally Posted by
panos
Unfortunately the problem remains..
Neither "make" worked nor the efforts looking for the QTDIR (everything seems OK).
Everything seems OK, because most likely everything is OK. I can't see any errors in the make output. The executable should be in the release directory (or debug if you want to use the debug version).
Re: QApplication: No such file or directory
Thank's a lot for your help. I think the problem was with the version 4.3.1. I installed Qt 4.1.1 and everything is working properly. Probably the problem was with the environment variables. With 4.1.1 installer the environment variables are set during the installation.
Thank's!