[Solved] Getting error compiling one of the tutorial examples
hi, im trying to compile part 13 or the "official" qt tutorial(http://doc.trolltech.com/4.3/tutorial-t13.html) but doing so gives me the following error:
"undefined reference to `vtable for Gameboard" while refering to this part of the code:
class GameBoard : public QWidget
(its the first part of the gameboard.h file)
im using qtcreator and the other parts compiled without any errors.
Do you know what i did wrong? I simply copied the given source code and compiled
Ok, this is old, but this error is not related with the age of the tutorial (BTW, Qt 4.7 tutorials are "here":http://doc.trolltech.com/4.7/tutorials.html).
How did you build the example? Did you try to run qmake again, then make?
Did you add all the source files to your .pro file? The error comes from the linker, and it's likely that it's caused by a non-compiled source file.
See a discussion of that error message here: http://bytes.com/topic/c/answers/161894-undefined-reference-vtable
theuser, I've just checked here, doing
this example compiled successfully. Reading the tutorial, I found that the class GameBoard is included in the project now and as I suspected, the build error you experienced happened because moc did not evaluate GameBoard yet. It's needed because GameBoard inherits QObject (via QWidget) and declares its own slots - moc is the "Qt Meta Object Compiler":http://doc.trolltech.com/4.7/moc.html, the guy who deals with Q_OBJECT stuff.
thank you, i ran qmake once and compiled afterwards and now it works just fine :)
edit: ah and thank you for the link to the newer tutorials i didnt know the one i worked with was "out of date"(though i guess the basic concepts are still the same)
[quote author="theuser" date="1291768946"]edit: ah and thank you for the link to the newer tutorials i didnt know the one i worked with was "out of date"(though i guess the basic concepts are still the same)[/quote]
Indeed, the concepts are still the same. Also, it is a Qt 4 example so it is expected to work with Qt 4.7 too.
I just pointed it's old because I could not find in the Qt 4.7 sources :-P