PDA

View Full Version : Vtable linker error



jhearon
21st July 2007, 05:43
Hi,
I've read the previous thread with vtable problem. I'm having a similar problem.
Fedora Core 6, QT 4.3, Fedora Eclipse with GCC.
I have QT 3.3 from the Fedora System install still in /usr/include/qt-3.3, but have pointed everything in my Eclipse project towards QT 4 includes and libs (/usr/include/qt4). I also have the env variables QTDIR, QTLIB, and QTINC pointed towards Qt4, and have Qt4 at the head of the PATH.

In addition I can compile the QT tutorials against QT4 using qmake, say on t1.pro, then make.

But when I try to compile in Fedora Eclipse using GCC in a CPP project I get a linker error:
undefined reference to `vtable for Window' etc.

The .cpp files compile, but the linker gives up. Below is what I have for my -L and -l commands. I've also tried using qmake to generate a makefile, and then model my IDE proj settings off those, but seems like I'm still missing a lib or have something incorrect.

Thanks for any help or info.

make -k all
Building target: QTwidget1
Invoking: GCC C++ Linker
g++ -L/usr -L/usr/bin -L/usr/lib -L/usr/lib/qt4 -L/usr/lib/qt4/lib -L/usr/lib/qt4/bin -o"QTwidget1" ./coinwidget.o ./main.o ./model.o ./window.o -lCoin -lSoQt -lsimage -lGL -lGLU -lQtOpenGL -lQtGui -lQtCore -lQt3Support
./coinwidget.o: In function `~CoinWidget':
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
./coinwidget.o:/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: more undefined references to `vtable for CoinWidget' follow
./main.o: In function `~Window':
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.h:15: undefined reference to `vtable for Window'
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.h:15: undefined reference to `vtable for Window'
./window.o: In function `Window':
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.cpp:5: undefined reference to `vtable for Window'
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.cpp:5: undefined reference to `vtable for Window'
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.cpp:5: undefined reference to `vtable for Window'
./window.o:/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.cpp:5: more undefined references to `vtable for Window' follow
./window.o: In function `Window::tr(char const*, char const*)':
/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.h:16: undefined reference to `Window::staticMetaObject'
collect2: ld returned 1 exit status
make: *** [QTwidget1] Error 1
make: Target `all' not remade because of errors.
Build complete for project QTwidget1_qt4

marcel
21st July 2007, 08:05
Do you have any virtual functions in CoinWidget or in Windows which are not implemented in the subclasses? Perhaps a virtual destructor or some other virtual function you forgot to implement...
This is usually the reason for this error.

Also, what about the Q_OBJECT macro? Did you add it to all the classes which implement/use signals/slots?

And where are the moc files? I am sure you must have at least one generated moc( for the window ). They should have been passed to gcc... Could you take a look and see if there are any moc files generated in you project?

Is your Eclipse set to call moc at all?

I could also be that Qt was compiled with another GCC version than you currently use. Is this the case?

Regards

jhearon
22nd July 2007, 18:28
Hi,
In that case then, maybe Fedora Eclipse is not the best IDE for trying to do this since still seems like it might require pushing the .h files thru moc, then linking those with other .cpp files.

I'll take a look at Kdevelop and see if that helps move things along.

regards,

marcel
22nd July 2007, 18:31
There is a tech preview for the Qt Eclipse Integration.
I have heard it is stable.

Maybe you can use this until they make the final release. Eclipse is an excellent IDE and I encourage you to use it.
Here is the link:http://trolltech.com/company/newsroom/announcements/press.2007-05-24.8884335791.
There is a version for linux too.

Regards