Difference between revisions of "Talk:Development/Tutorials/Saving and loading"

Jump to: navigation, search
(Compiling failed due to 'undefined reference to vtable ...')
(Solution for "undefined reference to `vtable for MainWindow'": new section)
Line 13: Line 13:
 
Tiny hint: if you quickly want to copy the source displayed in this tutorial, but are as annoyed as I am about the line numbering which is copied as well, use the edit function of this site to access the (barebone) sourcecode.
 
Tiny hint: if you quickly want to copy the source displayed in this tutorial, but are as annoyed as I am about the line numbering which is copied as well, use the edit function of this site to access the (barebone) sourcecode.
 
: I just tested this with Konq, Firefox and Opera and none of them copied the line numbering. What browser are you using? --[[User:Milliams|milliams]] 15:00, 22 March 2008 (CET)
 
: I just tested this with Konq, Firefox and Opera and none of them copied the line numbering. What browser are you using? --[[User:Milliams|milliams]] 15:00, 22 March 2008 (CET)
 +
 +
== Solution for "undefined reference to `vtable for MainWindow'" ==
 +
 +
When I tried to compile the code, I got the same error:
 +
 +
<code>undefined reference to `vtable for MainWindow'</code>
 +
 +
This is because you have to change CMakeLists.txt in order to generate .moc files. Just add this line:
 +
 +
<code>qt4_automoc(${tutorial4_SRCS})</code>
 +
 +
Then you also have to add this line at the bottom of mainwindow.cpp:
 +
 +
<code>#include "mainwindow.moc"</code>
 +
 +
This fixed the problem for me. Please try this and post your results so I can correct the tutorial.

Revision as of 14:12, 12 April 2008

Compiling failed due to 'undefined reference to vtable ...'

When compiling, cmake failed during the linking process. undefined reference to `vtable for MainWindow'

I received this error, after making one tiny mistake: I named my headerfile mainwindow.hpp instead of mainwindow.h Once renamed, everything should work fine.

Tiny hint: if you quickly want to copy the source displayed in this tutorial, but are as annoyed as I am about the line numbering which is copied as well, use the edit function of this site to access the (barebone) sourcecode.

I just tested this with Konq, Firefox and Opera and none of them copied the line numbering. What browser are you using? --milliams 15:00, 22 March 2008 (CET)

Solution for "undefined reference to `vtable for MainWindow'"

When I tried to compile the code, I got the same error:

undefined reference to `vtable for MainWindow'

This is because you have to change CMakeLists.txt in order to generate .moc files. Just add this line:

qt4_automoc(${tutorial4_SRCS})

Then you also have to add this line at the bottom of mainwindow.cpp:

#include "mainwindow.moc"

This fixed the problem for me. Please try this and post your results so I can correct the tutorial.


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal