PDA

View Full Version : QApplication: No such file or directory



Dolinski
23rd May 2007, 18:09
Hey,

im just starting to learn about Qt so i bought the book "C++ GUI PROGRAMMING WITH Qt 4" and followed all the instructions as far as installing Qt 4.1.1 and everything went through fine, or so i thought. When i went to the first example things kinda went wrong...

typing qmake -project and qmake hello.pro to create a Makefile for a hello.cpp file went fine as well, but when i type make i get:

hello.cpp:1:24: error: QApplication: No such file or directory
hello.cpp:2:18: error: QLabel: No such file or directory

as well several other errors because those files could not found.

the code im trying to compile is:


#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}

i am also pretty sure that i have qt4 in my path, i added the lines:
PATH=/usr/local/Trolltech/Qt-4.1.1/bin:$PATH
export PATH
to my .profile file in my home dir.

if anyone has any ideas as to what could be wrong please let me know, the book said that if i get an error like this its most likely because im using an older version qt, and that i should make sure that i am indeed using qt4, this seems kind of silly to me as i installed qt4.1.1 that came on a cd with the book...

thanks in advance.

jpn
23rd May 2007, 18:16
Could you please paste the output of "qmake -v" and then everything that follows "make" (including all the long compiler commands, errors and such)?

marcel
23rd May 2007, 19:30
You seem to be missing the Qt include dir path.
You should add $QTDIR/include to the additional include paths, so the compiler can find them.

jpn
23rd May 2007, 21:53
You seem to be missing the Qt include dir path.
The question is, why does qmake not handle it like it should..? :) Maybe he is using old qmake after all..

Dolinski
24th May 2007, 05:13
Hey,

i added the Qt Include dir to my path and it seems to be working great now. Thanks so much. oh and i dont know if really matters anymore, when i type qmake -v i get:
QMake version: 2.00a
Using Qt version 4.1.1 in /usr/local/Trolltech/Qt-4.1.1/lib

Thanks again for you help guys, i really appreciate it!! :)

-Dolinski