PDA

View Full Version : Problem with Qt 4.3.0



Simon.tux
18th July 2007, 19:44
Hello to all , I'm new in Qt . I have a small problem , today I have made the update to Qt 4.3.0 on my Linux box .
if I try to compile


#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QPushButton hello("Hello world!");
hello.resize(100, 30);

hello.show();
return app.exec();
}

Then I made .pro file using qmake -project and finally I made make file using qmake . Then it gave the following error :


g++ -c -pipe -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o hello.o hello.cpp
hello.cpp:24:25: error: QApplication: Nessun file o directory
hello.cpp:25:24: error: QPushButton: Nessun file o directory
hello.cpp:36:3: warning: no newline at end of file
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:29: error: ‘QApplication’ was not declared in this scope
hello.cpp:29: error: expected `;' before ‘app’
hello.cpp:31: error: ‘QPushButton’ was not declared in this scope
hello.cpp:31: error: expected `;' before ‘hello’
hello.cpp:32: error: ‘hello’ was not declared in this scope
hello.cpp:35: error: ‘app’ was not declared in this scope
hello.cpp: At global scope:
hello.cpp:27: warning: unused parameter ‘argc’
hello.cpp:27: warning: unused parameter ‘argv’
make: *** [hello.o] Error 1


I believe that I am an error of the path , you can help me to resolve and set the path on linux machine step to step.

sorry for my bad English ....

marcel
18th July 2007, 19:49
g++ -c -pipe -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o hello.o hello.cpp

Just take a look there. You are using the qt3 includes and make specs. This is not ok.
You must use the qt 4.3 includes. So find the path where you installed qt 4.3 and use that path.

Regards

Simon.tux
18th July 2007, 20:09
Sorry but I don't know how set the right path , I tried : export QTDIR=/usr/lib/qt4
, but nothing seem to change . I have the same problem also on hello world version qt3.

marcel
18th July 2007, 20:16
Yes, and after you export QTDIR, do:


export PATH=$QTDIR/bin:$PATH

You should really put these in a shell startup script, in your home dir or in /etc, so you won't have to set them each time you compile something.

Regards

Simon.tux
18th July 2007, 20:49
I had added the two lines to the file .bashrc , but nothing change.
Nothing seems to change also if I do from shell the lines

export QTDIR=/usr/lib/qt4

export PATH=$QTDIR/bin:$PATH

marcel
18th July 2007, 21:02
You must log out, and back in for the changes to take effect( when modifying bashrc)
type the following in a shell:


echo $QTDIR
and


echo $PATH
See if they are correct.

Regards

Simon.tux
18th July 2007, 21:27
I have restar the pc , but nothing .
here what I obtain :


Simontux@linux:~$ echo $QTDIR
/usr/lib/qt4





Simontux@linux:~$ echo $PATH
/usr/lib/qt4/bin:/lib/qt4//bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games


It semms correct. But if I compile I obtain the same error .

marcel
18th July 2007, 21:33
Seems a little weird.
Did you run qmake again after changing the environment variables?

Obviously this is an environment configuration error, so it should be easy to fix.

Could you check what versions moc and qmake return ( via the --v parameter )?

Regards

Simon.tux
18th July 2007, 21:41
Did you run qmake again after changing the environment variables?
Yes I do. But nothing .


Could you check what versions moc and qmake return ( via the --v parameter )?


Simontux@linux:~$ moc -v
Qt Meta Object Compiler version 26 (Qt 3.3.7)
Simontux@linux:~$ qmake -v
Qmake version: 1.07a (Qt 3.3.7)
Qmake is free software from Trolltech AS.


Some day ago I compiled normally with Qt 4.2....

marcel
18th July 2007, 21:47
But the versions are not correct :).
They still are from Qt3.

Also, there is a problem with your path variable from the previous post.
It is not consistent.

Once you will set the path correctly, it will work.
Are you sure that in /usr/lib/qt4/bin you have qt4 tools?

Anyway, that directory should come first in the path to make sure that v4.3 tools will always get called.

Regards

Simon.tux
18th July 2007, 22:02
Are you sure that in /usr/lib/qt4/bin you have qt4 tools?

then I have check it and the right directory is /usr/share/qt4/bin .

now I am in this situation


Simontux@linux:~$ echo $QTDIR
/usr/share/qt4/bin
Simontux@linux:~$ echo $PATH
/usr/share/qt4/bin/bin:/lib/qt4//bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games


but the moc and qmake versions are the same before, and if I compile I obtain the same error .

marcel
18th July 2007, 22:10
Because, again, the path is not correct:


/usr/share/qt4/bin/bin:/lib/qt4//bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games


There is an extra "/bin".
You should have:
QTDIR=/usr/share/qt4
PATH=/usr/share/qt4/bin:/lib/qt4//bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games

Regards

Simon.tux
18th July 2007, 22:17
I have corrected the path and now the all function .

Thank you so much.......