Click to See Complete Forum and Search --> : another major weird comiler error with QT


Bob54325
02-02-2002, 05:11 PM
I am making a KDE/QT application I do tmake and then make and with make I get these errors:

editCards.o: In function `QShared::deref(void)':
/usr/lib/qt2/include/qstring.h(.text+0x1f): undefined reference to `EditCards virtual table'
/usr/lib/qt2/include/qstring.h(.text+0x29): undefined reference to `EditCards::QPaintDevice virtual table'
collect2: ld returned 1 exit status
make: *** [quizzer] Error 1

Please help. Thank you in advance.

Qubit
02-03-2002, 04:28 AM
You've probably added your own slots and/or defined Q_OBJECT without 'moc'ing the header file.

Here's what to do:
1) Run 'moc' on every header file that contains the macro Q_OBJECT (you have to add that yourself, remember). This is: every class definition that contains slots for another class.
2) Compile the moc output with your usual QT compile flags
3) Link all the object files as usual.

There's some info on this in the QT docs:
QT Reference documentation > Overviews > Using the meta object compiler (moc)

<edit>Looks like jkm already fixed this problem in the other thread.</edit>

[ 03 February 2002: Message edited by: Glaurung ]

Bob54325
02-03-2002, 09:09 AM
Whoops. First I forget to moc my headers and then I forget to use QOBJECT. :o

Thanks you very much for answering.