You are not logged in.

#1 2008-05-25 19:09:23

Saend
Member
From: France
Registered: 2008-05-25
Posts: 11

[SOLVED]Compiling Qt4's Examples

Hi everyone smile
I spent about a weak trying to build Trolltech's examples of Qt4 lib and others basic code, everytime something is wrong.

I don't know if it's relevant, but before I tried everything I installed Kdemod (following their website's instructions).

Then I installed qt from extra repository (pacman -Sy qt), and tried "qmake -project" and "qmake":

[saend@Zina MiniCode]$ qmake -project 
[saend@Zina MiniCode]$ qmake
Error processing project file: Example.pro

So I tried "/opt/qt/bin/qmake --project && /opt/qt/bin/qmake":
qmake is working ... But then, make isn't

[saend@Zina MiniCode]$ make
g++ -c -pipe -Wall -W -march=i686 -mtune=prescott -O2 -pipe  -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT -I/opt/qt/mkspecs/linux-g++ -I. -I. -I/opt/qt/include -o main.o main.cpp
main.cpp:1:24: erreur: QApplication : No such file or directory
main.cpp:2:23: erreur: QPushButton : No such file or directory
main.cpp: In function 'int main(int, char**)':
main.cpp:6: erreur: 'QApplication' was not declared in this scope
main.cpp:6: erreur: expected `;' before 'app'
main.cpp:8: erreur: 'QPushButton' was not declared in this scope
main.cpp:8: erreur: expected `;' before 'bouton'
main.cpp:9: erreur: 'bouton' was not declared in this scope
main.cpp:11: erreur: 'app' was not declared in this scope
main.cpp: At global scope:
main.cpp:4: attention : unused parameter 'argc'
main.cpp:4: attention : unused parameter 'argv'
make: *** [main.o] Erreur 1

I wasn't understanding at all ... So I removed qt (pacman -Rcns qt), and I noticed that /opt/qt/bin/qmake still existed !
Now I can use "qmake" instead of "/opt/qt/bin/qmake", but make is still not working...


P.S:The code I'm trying to build:

#include <QApplication>
#include <QPushButton>

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

    QPushButton bouton("Salut les Zéros, la forme ?");
    bouton.show();

    return app.exec();
}

P.S.2: Please tell me if my english isn't understable smile

Last edited by Saend (2008-05-27 17:52:24)

Offline

#2 2008-05-25 19:49:43

pressh
Developer/TU
From: Netherlands
Registered: 2005-08-14
Posts: 1,719

Re: [SOLVED]Compiling Qt4's Examples

isn't /opt/qt/bin/qmake the qt3 version of qmake?

I have no problems compiling your code with qt4.4 using only

qmake -project
qmake
make

Offline

#3 2008-05-26 08:47:51

Saend
Member
From: France
Registered: 2008-05-25
Posts: 11

Re: [SOLVED]Compiling Qt4's Examples

Thanks for answering smile
I don't know ... But how do I install Qt4 ? Using pacman, or building from sources ?
Because I already tried both, and either qmake or make don't work then (as described before smile ).

Offline

#4 2008-05-26 09:10:44

Leiaz
Member
Registered: 2007-09-06
Posts: 7

Re: [SOLVED]Compiling Qt4's Examples

You install it with pacman.
The QT4's qmake is in /usr/bin/, you were running the qt3 version which is installed in /opt/qt.

Offline

#5 2008-05-26 09:12:53

pressh
Developer/TU
From: Netherlands
Registered: 2005-08-14
Posts: 1,719

Re: [SOLVED]Compiling Qt4's Examples

qt 4.3 from [extra] works fine.

pacman -S qt

check if you are using the correct qmake (the one in /usr/bin) after installing qt with

which qmake

and if you do, use the code I posted in my previous answer.

Offline

#6 2008-05-26 09:33:46

Saend
Member
From: France
Registered: 2008-05-25
Posts: 11

Re: [SOLVED]Compiling Qt4's Examples

Ok, let's do this.:D

bash-3.2# pacman -S qt
Résolution des dépendances...
Recherche des conflits possibles entre paquets...

Cibles: qt-4.3.4-1

Taille totale des paquets (téléchargement):   15,90 Mo
Taille totale des paquets (installation):   42,95 Mo

Procéder à l'installation? [O/n]
:: Récupération des paquets du dépôt extra...
 qt-4.3.4-1-i686           15,9M  451,9K/s 00:00:36 [#####################] 100%
Analyse de l'intégrité des paquets...
(1/1) Analyse des conflits entre fichiers           [#####################] 100%
(1/1) Installation qt 
bash-3.2# which qmake
/usr/bin/qmake

Ok ... Everything seems Ok.

[saend@Zina MiniCode]$ qmake -project
[saend@Zina MiniCode]$ qmake
[saend@Zina MiniCode]$ make
g++ -c -pipe -march=i686 -mtune=generic -O2 -pipe -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -I. -I. -o main.o main.cpp
main.cpp:1:27: erreur: Qt/QApplication : Aucun fichier ou répertoire de ce type
main.cpp:2:28: erreur: Qt/QPushButton.h : Aucun fichier ou répertoire de ce type
main.cpp: In function 'int main(int, char**)':
main.cpp:6: erreur: 'QApplication' was not declared in this scope
main.cpp:6: erreur: expected `;' before 'app'
main.cpp:8: erreur: 'QPushButton' was not declared in this scope
main.cpp:8: erreur: expected `;' before 'bouton'
main.cpp:9: erreur: 'bouton' was not declared in this scope
main.cpp:11: erreur: 'app' was not declared in this scope
main.cpp: At global scope:
main.cpp:4: attention : unused parameter 'argc'
main.cpp:4: attention : unused parameter 'argv'
make: *** [main.o] Erreur 1

hmm

Offline

#7 2008-05-27 11:43:28

Saend
Member
From: France
Registered: 2008-05-25
Posts: 11

Re: [SOLVED]Compiling Qt4's Examples

Bump ?

Edit: Thanks pressh smile

Last edited by Saend (2008-05-27 14:13:19)

Offline

#8 2008-05-27 12:15:55

pressh
Developer/TU
From: Netherlands
Registered: 2005-08-14
Posts: 1,719

Re: [SOLVED]Compiling Qt4's Examples

Saend wrote:

Bump ?

sorry I forgot a bit about it roll
I'll try to look in it later today.

Last edited by pressh (2008-05-27 12:22:00)

Offline

#9 2008-05-27 17:31:38

gnud
Member
Registered: 2005-11-27
Posts: 182

Re: [SOLVED]Compiling Qt4's Examples

Same thing happened with me when I was coding up a teeny QT program.

Try replacing the includes with
#include <QtGui/QApplication>
#include <QtGui/QPushButton>

I don't know what is wrong, but this at least solved my problem smile

Offline

#10 2008-05-27 17:51:59

Saend
Member
From: France
Registered: 2008-05-25
Posts: 11

Re: [SOLVED]Compiling Qt4's Examples

It also worked for me ! Thank you so much !!!
We still don't know why ... But at least I know how to make it work !
Thank you gnud and pressh ^^

Offline

#11 2008-05-27 18:08:49

gnud
Member
Registered: 2005-11-27
Posts: 182

Re: [SOLVED]Compiling Qt4's Examples

Actually, I know what is wrong, but I dont know why.
The subdirectories of /usr/include/qt are not searched. I would think that they would be by default, since the default setting for qmake is to link against both the QtCore and the QtGui module.

Anyway, on examples with more files and more includes, there is no need to change all the includes. Just change the .pro file. Add the correct directories to the INCLUDEPATH variable. The directories are something like /usr/include/qt/Qt[Core|Gui|Network|etc].

Offline

Board footer

Powered by FluxBB