PDA

View Full Version : Undefined reference to vtable.



hakermania
10th September 2011, 12:56
I know, YES, I know, I've searched the forum and the google but I still don't know what I'm doing wrong :(
I am trying to use QNetWork for a network operation, as somebody suggested (http://www.qtcentre.org/threads/44514-QProcess-start-hangs-application?p=202705#post202705)

As you may know, static functions do not allow calling 'this', so I am trying via a static function available from all the piece of code I have to make QNetwork work.

My problem is that through this static function I am trying to call a non-static function so as to be able to call 'connect' (which needs 'this' which need non-static function -_-)
So, this is how I call my non-static function:


// abc() is static and is called by some other cpp files of my code
void Global::abc(){
// start_abc() is not static so it cannot be called as Global::start_abc(), that's why I'm making an object here
Global *live = new Global();
live->start_abc();
}


And:

error: undefined reference to `vtable for Global'

I feel that it's obvious BUT :/ :(

mvuori
10th September 2011, 13:45
Probably the error message has nothing to do with something being static or "this or that". For some pointers about where the problem might be, see http://www.theirishpenguin.com/2007/07/01/qobject-qmake-and-sadness-undefined-reference-to-vtable/

hakermania
10th September 2011, 14:30
I don't know how this was solved but I edited my project file, did the change back(so actually nothing changed), saved the project file, compiled and no error...

Is this odd?

SixDegrees
10th September 2011, 18:10
No; I was about to suggest that you simply try doing a 'make clean' and a rebuild. This is most often the cure for vtable errors; a symbol table mismatch occurs because of some change, usually in the headers and usually because one of the Qt tools hasn't been run on the altered file to update its Qt macros and other features.