PDA

View Full Version : QApplication: No such file or directory



panos
25th August 2007, 17:07
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

jpn
25th August 2007, 17:35
Are you using qmake? What does the compiler command look like?

panos
26th August 2007, 09:10
I am using the following commands:
>qmake -project
>qmake hello.pro
>make hello

jpn
26th August 2007, 11:50
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.

panos
26th August 2007, 13:54
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..

marcel
26th August 2007, 13:57
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.

jpn
26th August 2007, 14:22
Ah, I think I found the problem. Try plain "make" instead of "make hello".

panos
26th August 2007, 18:15
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

marcel
26th August 2007, 18:30
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

jacek
26th August 2007, 18:31
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).

panos
27th August 2007, 11:08
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!