QT-Tutorial

Jan-Benedict Glaw jbglaw at lug-owl.de
Sat Sep 16 00:14:46 CEST 2000


On Fri, Sep 15, 2000 at 07:26:53PM +0200, Markus Wigge wrote:
> Hi folks,
> 
> /tmp/ccPaf8BE.o: In function `main':
> /tmp/ccPaf8BE.o(.text+0x17): undefined reference to `QApplication::QApplication(int &, char **)'
> /tmp/ccPaf8BE.o(.text+0x2f): undefined reference to `QPushButton::QPushButton(char const *, QWidget *, char const *)'
> /tmp/ccPaf8BE.o(.text+0x42): undefined reference to `QPushButton::resize(int, int)'
> /tmp/ccPaf8BE.o(.text+0x55): undefined reference to `QApplication::setMainWidget(QWidget *)'
> /tmp/ccPaf8BE.o(.text+0x64): undefined reference to `QWidget::show(void)'
> /tmp/ccPaf8BE.o(.text+0x70): undefined reference to `QApplication::exec(void)'
> /tmp/ccPaf8BE.o(.text+0x83): undefined reference to `QPushButton::~QPushButton(void)'
> /tmp/ccPaf8BE.o(.text+0x91): undefined reference to `QApplication::~QApplication(void)'
> /tmp/ccPaf8BE.o(.text+0xc6): undefined reference to `QPushButton::~QPushButton(void)'
> /tmp/ccPaf8BE.o(.text+0xd7): undefined reference to `QApplication::~QApplication(void)'
> collect2: ld returned 1 exit status
> 
> Was muss ich dem compiler mit auf den Weg geben damit der das
> hinkriegt?

Der Compiler an sich hat keine Probleme, aber "ld", der Linker.
Der soll z.B. die Klasse "QApplication" finden, die Du in Deinem
Programm benutzt. Aber diese Klasse hast Du nicht geschrieben, die
liegt in einer library. ...und die kannst Du mit dazulinken, indem
Du sie einfach angibts:

g++ my_example.cpp -lqt -o my_example

Die Versionsnummer und das ".so." der lib wird ganz weggelassen, und
das Prefix "lib" ebenso. So wird aus "libqt.so.1.2.3.3" dann nur noch
"qt". ...und das soll der Linker dazulinken, dafür ist der Parameter
"-l" gedacht. ...und wenn die Lib in einem Verzeichnis, das nicht in
der /etc/ld.so.conf steht, ist, dann solltest Du auch noch
"-L/path/to/library/" mitangeben.

Mfg, JBG


-- 
Fehler eingestehen, Größe zeigen: Nehmt die Rechtschreibreform zurück!!!
/* Jan-Benedict Glaw <jbglaw at lug-owl.de> -- +49-177-5601720 */
keyID=0x8399E1BB fingerprint=250D 3BCF 7127 0D8C A444 A961 1DBD 5E75 8399 E1BB
     "insmod vi.o and there we go..." (Alexander Viro on linux-kernel)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://lug-owl.de/pipermail/linux/attachments/20000916/d6971e6f/attachment.sig>


More information about the Linux mailing list