how to solve this the error undefined reference in this case
-
4.8.6/Linux5/x86_64/lib -o simpletreemodel main.o treeitem.o treemodel.o moc_treemodel.o qrc_simpletreemodel.o -L/in/qt-4.8.6/Linux5/x86_64/lib -lQtGui -L/in/qt-4.8.6/Linux5/x86_64/lib -L/usr/X11R6/lib -lQtCore -lpthread
main.o: In functionmyclass::myclass(QObject*)': main.cpp:(.text+0x61f): undefined reference to
vtable for myclass'
main.o: In functionmyclass::~myclass()': main.cpp:(.text._ZN7myclassD2Ev[_ZN7myclassD5Ev]+0xb): undefined reference to
vtable for myclass'
main.o: In functionmyclass::~myclass()': main.cpp:(.text._ZN7myclassD0Ev[_ZN7myclassD5Ev]+0xb): undefined reference to
vtable for myclass'
collect2: ld returned 1 exit status
make: *** [simpletreemodel] Error 1 -
4.8.6/Linux5/x86_64/lib -o simpletreemodel main.o treeitem.o treemodel.o moc_treemodel.o qrc_simpletreemodel.o -L/in/qt-4.8.6/Linux5/x86_64/lib -lQtGui -L/in/qt-4.8.6/Linux5/x86_64/lib -L/usr/X11R6/lib -lQtCore -lpthread
main.o: In functionmyclass::myclass(QObject*)': main.cpp:(.text+0x61f): undefined reference to
vtable for myclass'
main.o: In functionmyclass::~myclass()': main.cpp:(.text._ZN7myclassD2Ev[_ZN7myclassD5Ev]+0xb): undefined reference to
vtable for myclass'
main.o: In functionmyclass::~myclass()': main.cpp:(.text._ZN7myclassD0Ev[_ZN7myclassD5Ev]+0xb): undefined reference to
vtable for myclass'
collect2: ld returned 1 exit status
make: *** [simpletreemodel] Error 1Show the declaration of
myclass
and the definition ofmyclass::myclass
andmyclass::~myclass
. -
Hi,
In addition to what @kshegunov wrote, did you add or remove the Q_OBJECT macro from your class ? If so you likely forgot to re-run qmake before building your application.
-
yes and if i put Q_OBJECT then i get this error do i have start from qmake again
-
yes and if i put Q_OBJECT then i get this error do i have start from qmake again
@Qt-Enthusiast
Show code :) -
https://paste.ofcode.org/iphXzSpzkkML3d9wKAEftq
What I am missing .Event if I rerun the from qmake , I am getting the error
-
https://paste.ofcode.org/iphXzSpzkkML3d9wKAEftq
What I am missing .Event if I rerun the from qmake , I am getting the error
@Qt-Enthusiast said in how to solve this the error undefined referene in this case:
What I am missing.
Nothing as far as I can see. Try what @hskoglund suggested and do a full rebuild.