PDA

View Full Version : VTABLE - issue



sajis997
17th June 2011, 17:58
Hello forum,

i believe this issue is already discussed here. But i could not figure out any reason of the following error related to vtable:





../../Build/H3DSceneEditor/Debug/H3DSceneHierarchy.o: In function `~H3DSceneHierarchy':
/home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:19: undefined reference to `vtable for H3DSceneHierarchy'
/home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:19: undefined reference to `vtable for H3DSceneHierarchy'
/home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:19: undefined reference to `vtable for H3DSceneHierarchy'
../../Build/H3DSceneEditor/Debug/H3DSceneHierarchy.o: In function `H3DSceneHierarchy':
/home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:13: undefined reference to `vtable for H3DSceneHierarchy'
/home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:13: undefined reference to `vtable for H3DSceneHierarchy'
collect2: ld returned 1 exit status
make[2]: *** [../../bin/H3Dd] Error 1
make[2]: Leaving directory `/home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor'
make[1]: *** [sub-H3DSceneEditor-make_default-ordered] Error 2








class H3DSceneHierarchy : public QObject
{
Q_OBJECT
public:

H3DSceneHierarchy(QObject *parent = 0);

~H3DSceneHierarchy();

}









And in the source file


[CODE]
H3DSceneHierarchy::H3DSceneHierarchy(QObject *parent)
: QObject(parent)
{

}


H3DSceneHierarchy::~H3DSceneHierarchy()
{

}






Is there anything wrong in the above code ?


Regards
Sajjad

Rachol
17th June 2011, 18:09
First of all I think you are missing a semicolon after class declaration, then make sure you have header and source file for the class and correct include.

You could also write which are the error lines. Cause I can't see what line number refers to.

stampede
17th June 2011, 18:10
Semicolon after class declaration is missing, nothing more wrong with this I think.

---
edit: too slow ;)
btw. line 19:

H3DSceneHierarchy.cpp:19: undefined reference to `vtable for H3DSceneHierarchy'

If you keep getting this error after adding the semicolon, make sure moc is generated for this header ( add it to HEADERS list in .pro file, or run moc yourself )

SixDegrees
17th June 2011, 18:13
Also, do a 'make clean' followed by a new run of 'qmake' and 'make'. Fouled vtables are often caused by failure to invoke qmake, which generates Qt's metacode, and by failure to clean a build, which causes mismatched source code components to be compiled together.

sajis997
17th June 2011, 18:25
Thanks for such a quick reply!!


1. I included the semicolon that i missed.

2. Ran "make clean && make"


And unfortunately the same error . I have also checked the .pro file here i already have the header and source file defined.


Any other hint to resolve this?





#ifndef H3DSCENEHIERARCHY_H
#define H3DSCENEHIERARCHY_H

#include <iostream>
#include <vector>

#include <QObject>
#include <QString>

//#include "H3DSceneHierarchyObserver.h"

class H3DNodeData;
class H3DRouteLink;
class H3DProperty;

//!H3DSceneHierarchy is alike the ProcessorNetwork in the Voreen API
class H3DSceneHierarchy : public QObject /* Observable<H3DSceneHierarchyObserver> */
{
Q_OBJECT
public:

H3DSceneHierarchy(QObject *parent = 0);

~H3DSceneHierarchy();

private:



//store the list of nodes in the scene hierarchy
//which has been dragged into the editor
std::vector<H3DNodeData*> m_nodeList;


//!store the list of routing links in the scene hierarchy
std::vector<H3DRouteLink*> m_routeLinkList;



};

#endif // H3DSCENEHIERARCHY_H



The separate .cpp file contanis the following:




#include "H3DSceneHierarchy.h"
#include "H3DNodeData.h"


#include "H3DRouteLink.h"
#include "H3DProperty.h"


#include <algorithm>


H3DSceneHierarchy::H3DSceneHierarchy(QObject *parent)
: QObject(parent)
{

}


H3DSceneHierarchy::~H3DSceneHierarchy()
{
/*!
* remove all the nodes, hierarchy and route connections from the scene
* hierarchy and deletes them
*/
//clear();
}





Regards
Sajjadul

squidge
17th June 2011, 18:34
Since you are using Q_OBJECT, have you run qmake?

Rachol
17th June 2011, 18:34
did you run qmake?

sajis997
17th June 2011, 19:04
I am using QtCreator to edit the project.


I just closed it down and started again. And now it works!!!


Thanks all of you.


Any explanation of it?


Regards
Sajjad

Rachol
17th June 2011, 19:08
What's the OS are you using?

hypnotic401
17th June 2011, 19:11
Make sure all methods defined in the header (Especially the slots and signals as they are Q_OBJECT and Qmake specific) have an implementation in your source file. If you do not implement a method that is Q_OBJECT specific (ie. signals and slots) you will get this error.

sajis997
17th June 2011, 19:12
Ubuntu 8.10

Should it be a reason?

Rachol
17th June 2011, 19:19
I guess not, but if I remember correctly something like that happened to me before, so next time it happens I want to know if that is just system related. Unfortunately I have no idea what system I used cause I do programming on OS X, Vista, Kubuntu simultaneously...

wysota
17th June 2011, 19:52
The reason is you didn't run qmake as a number of people already pointed out.