Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ - Undefined reference to `vtable

Tags:

c++

qt

I was wondering why I was getting this error: undefined reference to `vtable for BaseRenderer'

I tried searching around but cannot seem to figure this out. I've tried getting rid of the virtual function, removing the constructor, etc.

My BaseRenderer.h

class BaseRenderer : public Renderer
{
 Q_OBJECT

    public:
        BaseRenderer();
        BaseRenderer(QWidget *parent);
        void paintGL();

        virtual ~BaseRenderer();

 public slots:
  void loadDialog();

 signals:

    protected:
        Mesh loadMesh(string fileName);

    private:

        OBJParser objParser;
        Mesh baseTerrain;

};

My BaseRenderer.cpp

BaseRenderer::BaseRenderer()              <------ Error leads me here
{
}

BaseRenderer::BaseRenderer(QWidget *parent) : Renderer(parent)
{

}

BaseRenderer::~BaseRenderer()
{
    //dtor
}

How would I go about getting rid of this issue? I also hear it may be the compiler...? Thanks for the help :)

like image 782
Aero Chocolate Avatar asked Dec 01 '10 05:12

Aero Chocolate


2 Answers

Since Q_OBJECT is in the parent class, Renderer, you don't have to also include it BaseRenderer. Just get rid of Q_OBJECT and it should work :)

like image 197
Pellanor Avatar answered Sep 24 '22 06:09

Pellanor


See 'What does it mean that the "virtual table" is an unresolved external?' in the C++ FAQ Lite.

like image 39
Karl Knechtel Avatar answered Sep 23 '22 06:09

Karl Knechtel