Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[gelöst] QT- und kde-bibliotheken nicht richtig verlinkt?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
markusk21
Apprentice
Apprentice


Joined: 07 Oct 2004
Posts: 216
Location: Hannover

PostPosted: Sun Jul 23, 2006 2:10 pm    Post subject: [gelöst] QT- und kde-bibliotheken nicht richtig verlinkt? Reply with quote

Hallo,
ich wollte mal wieder etwas ins Programmieren reinschnuppern.
Mein erstes X11-Programm sucht die Datei "qapplication.h". Die ist zu finden in
/usr/include/qt4/Qt/qapplication.h

Allerdings gibt c++ die Meldung:
Quote:

firstprog.cpp:20:41: qapplication.h: Datei oder Verzeichnis nicht gefunden


Mit
Code:

#include <qt4/Qt/qapplication.h>

funktioniert dies dann, aber dann werden andere q-Bibliotheken nicht gefunden die in qapplication eingebunden werden.

Mit kapplication.h und kmainwindow.h ist es übrigens das selbe.

Muss ich ein zusätzliches paket mergen oder wo liegt der Fehler?

Gruß
Markus


Last edited by markusk21 on Tue Aug 08, 2006 10:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
firefly
Watchman
Watchman


Joined: 31 Oct 2002
Posts: 5329

PostPosted: Sun Jul 23, 2006 2:45 pm    Post subject: Reply with quote

öhm wie sieht deine gcc cmd zeile aus ?
_________________
Ein Ring, sie zu knechten, sie alle zu finden,
Ins Dunkel zu treiben und ewig zu binden
Im Lande Mordor, wo die Schatten drohn.
Back to top
View user's profile Send private message
hoernerfranz
Tux's lil' helper
Tux's lil' helper


Joined: 29 Feb 2004
Posts: 135
Location: Baden

PostPosted: Sun Jul 23, 2006 4:52 pm    Post subject: Reply with quote

vermutlich fehlen die variablen QTDIR und KDEDIR im environment.
_________________
Remember: If brute force doesn't work, you're just not using enough.
Back to top
View user's profile Send private message
markusk21
Apprentice
Apprentice


Joined: 07 Oct 2004
Posts: 216
Location: Hannover

PostPosted: Sun Jul 23, 2006 8:20 pm    Post subject: Reply with quote

Also Frage Nr. 1 (Kompiler-Befehl):

c++ firstprog.cpp

Mit gcc sieht es genau so aus:
Quote:

$ gcc firstprog.cpp
firstprog.cpp:20:41: qapplication.h: Datei oder Verzeichnis nicht gefunden
firstprog.cpp:21:39: qmainwindow.h: Datei oder Verzeichnis nicht gefunden
firstprog.cpp: In function `int main(int, char**)':
firstprog.cpp:27: Fehler: »QApplication« wurde in diesem Gültigkeitsbereich nicht definiert
firstprog.cpp:27: Fehler: expected `;' vor "app"
firstprog.cpp:30: Fehler: »QMainWindow« wurde in diesem Gültigkeitsbereich nicht definiert
firstprog.cpp:30: Fehler: »window« wurde in diesem Gültigkeitsbereich nicht definiert
firstprog.cpp:30: Fehler: »QMainWindow« is not a type
firstprog.cpp:37: Fehler: »app« wurde in diesem Gültigkeitsbereich nicht definiert


Code:

export QTDIR="/usr/lib/qt4/"

habe ich in /etc/profile eingefügt und auch spaßeshalber mal
Code:

QTDIR="/usr/lib/qt4" gcc firstprog.cpp
ausgeführt.
Keine Änderung in sicht.

Das ist der Quellcode:
Code:

#include <qapplication.h>       //QApplication
#include <qmainwindow.h>        //QMainWindow

using namespace std;

int main(int argc, char **argv){
        // Create a QApplication object (required)
        QApplication app(argc, argv);

        // Create a QMainWindow object
        QMainWindow *window = new QMainWindow();

        // Move and resize the QMainWindow object
        // left=200, top=200,, width=400, hight=300
        window->setGeometrie(200,200,400,300);

        // main window = QMainwindow object
        app.setMainWidget(window);

        // set Window Title
        window->setCaption("My QMainWindow example");

        // Show the window
        window->show();

        // Go to the main loop (required)
        return app.exec();
}



Wie müssen denn die QTDIR und KDEDIR aussehen und wo füge ich sie ein (ist /etc/profile richtig)?
Back to top
View user's profile Send private message
hoernerfranz
Tux's lil' helper
Tux's lil' helper


Joined: 29 Feb 2004
Posts: 135
Location: Baden

PostPosted: Sun Jul 23, 2006 8:43 pm    Post subject: Reply with quote

markusk21 wrote:

Code:

export QTDIR="/usr/lib/qt4/"



das kann nicht klappen, denn die header von qt4 sind in /usr/include/qt4
allerdings weiss ich auch nicht genau wie QTDIR f. qt4 sein muss,
bei qt3 ist es jedenfalls /usr/qt/3 - /usr/qt/4 gibts aber nicht
(könnte man mal anlegen und von dort aus dann lib bzw. include als symlinks auf /usr/lib/qt4 bzw /usr/include/qt4).
QTDIR kannst du global in /etc/profile definieren, oder auch userspezifisch in ~/.bashrc
_________________
Remember: If brute force doesn't work, you're just not using enough.
Back to top
View user's profile Send private message
markusk21
Apprentice
Apprentice


Joined: 07 Oct 2004
Posts: 216
Location: Hannover

PostPosted: Mon Jul 24, 2006 7:55 am    Post subject: Reply with quote

Oh, man. Ich dachte eigentlich gerade das wäre unter Gentoo kein Problem ....
Es funktioniert immer noch nicht!!!
Folgendes habe ich schon mal herausgefunden:

qapplication.h gibt es hier:
Quote:
/usr/qt/3/include/qapplication.h
/usr/include/qt4/Qt/qapplication.h
/usr/include/qt4/QtGui/qapplication.h


Meine /etc/profile sieht jetzt so aus:
Quote:
export QTDIR="/usr/qt/3"
export KDEDIR="/usr/kde/3.5"
export LD_LIBRARY_PATH=$QTDIR/lib:$KDEDIR:$LD_LIBRARY_PATH
export LIBRARY_PATH=$QTDIR/include:$KDEDIR:$LIBRARY_PATH
export PATH=$QTDIR/bin:$KDEDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/include habe ich auch probiert.

Nach Änderungen habe ich immer
Quote:
source /etc/profile
ausgeführt
Aber qapplication.h wird immer noch nicht gefunden!!!!

Ich habe es auch mit /usr/include/qt4 als QTDIR versucht. Selbes Ergebnis. Dort gibt es aber auch keine qapplication.h (s.o.).



Verdammt das kann doch nicht so schwer sein!! emerge funktioniert tadellos!!!! Wo liegt das Problem???
Ich muss doch nicht "root" sein um eigene Programme zu kompilieren, oder?
Back to top
View user's profile Send private message
scourge
n00b
n00b


Joined: 13 Jun 2005
Posts: 51
Location: Germany

PostPosted: Mon Jul 24, 2006 9:11 am    Post subject: Reply with quote

Zum einen heißt das Geometry und nicht Geometrie, und zum anderen

Code:
g++ firstprog.cpp  -I/usr/qt/3/include -L/usr/qt/3/lib -lqt -o firstprog


Gruß,
Thomas
Back to top
View user's profile Send private message
markusk21
Apprentice
Apprentice


Joined: 07 Oct 2004
Posts: 216
Location: Hannover

PostPosted: Mon Jul 24, 2006 10:18 am    Post subject: Reply with quote

Danke für den Tipp.

Die g++ Zeile läuft! Aber kann man die Bibliotheken nicht in einen Pfad einbinden?
Back to top
View user's profile Send private message
markusk21
Apprentice
Apprentice


Joined: 07 Oct 2004
Posts: 216
Location: Hannover

PostPosted: Sat Aug 05, 2006 3:15 pm    Post subject: Reply with quote

Ok,
nach langem suchen und experimentieren bin ich afu folgende Einträge in die /etc/profile gekommen:
Code:
QTDIR="/usr/qt/3:${QTDIR}"
PATH=$QTDIR/bin:$PATH
LD_LIBRARY_PATH=$QTDIR/include:$QTDIR/lib:$LD_LIBRARY_PATH


Kann das jemand bestätigen? Es funktioniert leider nicht, habe source /etc/profile ausgeführt aber bekomme immer noch Fehlermeldungen:

Quote:
$ g++ qapp.cpp -lqt -o qapp
qapp.cpp:2:26: qapplication.h: Datei oder Verzeichnis nicht gefunden
qapp.cpp:3:20: qlabel.h: Datei oder Verzeichnis nicht gefunden
Back to top
View user's profile Send private message
XMath
Guru
Guru


Joined: 14 Aug 2004
Posts: 435
Location: Germany, Gaimersheim

PostPosted: Sun Aug 06, 2006 7:18 am    Post subject: Reply with quote

Moin,
ja kann ich bestätigen: Funktioniert so nicht ;).

Du hast zwar damit den Pfad für die Bibliotheken gesetzt, aber nicht den Pfad für die Includes. Deswegen nutzt man meist ein Makefile.
Könntest höchstens mal Ausprobieren ob es hilft $QTDIR/include in PATH aufzunehmen.
Back to top
View user's profile Send private message
markusk21
Apprentice
Apprentice


Joined: 07 Oct 2004
Posts: 216
Location: Hannover

PostPosted: Mon Aug 07, 2006 8:32 pm    Post subject: Reply with quote

Also, ich komme nicht weiter.

Ich will doch nur ein x11-Programm schreiben können! Es kann doch nicht sein, dass mir keiner sagen kann, wie ich eine Gentoo-Distribution dazu bekomme ein Programm mit KDevelop erstellen und kompilieren zu können.

Ich habe einen weiteren Thread aufgemacht weil ich mit KDevelop ein QT-Programm erstellen möchte und ich einfach keinen Schritt weiter komme. Hier ist er.
Back to top
View user's profile Send private message
branitar
n00b
n00b


Joined: 31 Mar 2006
Posts: 10

PostPosted: Tue Aug 08, 2006 7:39 am    Post subject: Reply with quote

Versuch mal #include <QApplication> statt #include <qapplication.h>. Oder besser noch QCoreApplication.
In Qt4 kann man die Klassen angeben anstelle der .h-Files. Frag mich nicht warum, aber offenbar verspricht Trolltech sich davon etwas...
Back to top
View user's profile Send private message
_hephaistos_
Advocate
Advocate


Joined: 07 Apr 2004
Posts: 2694
Location: salzburg, austria

PostPosted: Tue Aug 08, 2006 8:55 am    Post subject: Reply with quote

sei mir echt nicht böse, aber das kann so nicht funktionieren!
du musst natürlich gegen qt etc. selber linken.
dh: mit c++ yourfile.cpp wirds nix werden!

wie im anderen thread geschrieben: probier es mit einem qmake project!
bzw. wär gut, wenn du dich ein wenig damit auseinandersetzt, zB mal mit dem QT Tutorial anfangen:
QT3: http://doc.trolltech.com/3.0/tutorial.html
QT4: http://doc.trolltech.com/4.0/tutorial.html

irgendein mod sollte diese threads dann verbinden oder so hm? sonst hilfts dem nächsten auch nicht weiter :D
_________________
-l: signature: command not found
Back to top
View user's profile Send private message
franzf
Advocate
Advocate


Joined: 29 Mar 2005
Posts: 4565

PostPosted: Tue Aug 08, 2006 9:35 am    Post subject: Reply with quote

Was willst du eigentlich schreiben?
Ein Projekt mit QT3 oder mit QT4?

Dein erster Post deutet darauf hin dass es QT4 sein soll.
Dass du mit kdevdesigner dein UI erstellst auf QT3.
Dein Makefile sagt auch QT3:
Code:
[...]
QT_INCLUDES = -I/usr/qt/3/include
QT_LDFLAGS = -L/usr/qt/3/lib
[...]

In diesen beiden Zeilen kannst du z.B. die Pfade zu deinen qt4-includes und libs einsetzen.
Wenn du mit QT4 arbeitest kannst du auch z.B. statt
#include <qapplication.h>
ein
#include <QApplication>
usw. nehmen. So weiß man dann gleich dass es QT4 ist ;)

Grüße
Franz
Back to top
View user's profile Send private message
SinoTech
Advocate
Advocate


Joined: 20 Mar 2004
Posts: 2579
Location: Neunkirchen / Saarland / Germany

PostPosted: Tue Aug 08, 2006 9:57 am    Post subject: Reply with quote

branitar wrote:
Versuch mal #include <QApplication> statt #include <qapplication.h>. Oder besser noch QCoreApplication.
In Qt4 kann man die Klassen angeben anstelle der .h-Files. Frag mich nicht warum, aber offenbar verspricht Trolltech sich davon etwas...

Es dürften beides Header files, nur das bei zweiterem die Dateiererweitung fehlt (So wie es "iostream.h" und "iostream" gibt).

Mfg

Sino
_________________
Help to answer the unanswered
Back to top
View user's profile Send private message
_hephaistos_
Advocate
Advocate


Joined: 07 Apr 2004
Posts: 2694
Location: salzburg, austria

PostPosted: Tue Aug 08, 2006 10:04 am    Post subject: Reply with quote

gut, dass er/sie/es einen zweiten thread aufgemacht hat.
weil dort wär das problem eigentlich schon gelöst...
_________________
-l: signature: command not found
Back to top
View user's profile Send private message
Carlo
Developer
Developer


Joined: 12 Aug 2002
Posts: 3356

PostPosted: Tue Aug 08, 2006 5:15 pm    Post subject: Reply with quote

hoernerfranz wrote:
vermutlich fehlen die variablen QTDIR und KDEDIR im environment.

QTDIR ist nur für Qt 3.x zu verwenden. Für Qt 4 nimmst du pkg-config.

Für QtCore gilt beispielsweise "-I`pkg-config --variable=includedir QtCore`".
_________________
Please make sure that you have searched for an answer to a question after reading all the relevant docs.
Back to top
View user's profile Send private message
markusk21
Apprentice
Apprentice


Joined: 07 Oct 2004
Posts: 216
Location: Hannover

PostPosted: Tue Aug 08, 2006 10:26 pm    Post subject: Reply with quote

franzf wrote:
Was willst du eigentlich schreiben?
Ein Projekt mit QT3 oder mit QT4?

Dein erster Post deutet darauf hin dass es QT4 sein soll.
Dass du mit kdevdesigner dein UI erstellst auf QT3.


Das war ein entscheidender Hinweis!!!! Mir war gar nicht klar, dass ich 2 QT-Versionen installiert habe, ganz zu schweigen davon, dass ich alte Header etc einbinde.
Ich habe jetzt (hoffentlich vollständig) meine Versuche auf QT4 umgestellt. So funktioniert auch unter Kdevelop einiges mehr auf Anhieb :D .
Vielen Dank noch mal an alle.
Ich werde versuchen, die vielen Tipps und Hinweise nach und nach abzuarbeiten.
Anfangen werde ich mit [url] http://doc.trolltech.com/4.0/tutorial.html[/url]
und dann weitersehen.
LG.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum