开发者

C++ - Undefined reference to `vtable

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开发者_如何学Go 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 :)


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 :)


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


I think this highly unhelpful message is really complaining about you not providing definitions for the other functions in your BaseRenderer class, as your baseRenderer.cpp file seems to only have the constructor and destructors.


Make sure you implement all declared methods, especially the slot. Then check that your header is listed in the HEADERS section in the .pro file and then run qmake.


I would guess it's the same issue I had when asking this question: Why won't this compile (link) with the Q_OBJECT macro in place?

Try rerunning qmake like paxdiablo and Tobias suggest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜