troubleshooting Question

undefined reference to vtable...

Avatar of Cheney
Cheney asked on
Programming
2 Comments1 Solution7276 ViewsLast Modified:
I get this linker error when I try to compile my app (using MinGW inside the eclipse IDE)

"undefined reference to 'vtable for CD3DXModel"

The affect files are:

==========================================================
CModel.h
==========================================================
#ifndef CHENEY_CMODEL_INCLUDED
#define CHENEY_CMODEL_INCLUDED

#include <d3dx9.h>

#include "Debug.h"
#include "CCamera.h"

class CModel
{
      protected:
            LPDIRECT3DDEVICE9      m_pD3DDevice;
            D3DXMATRIX                  m_mtxWorld;
            float                        m_fSphereSize;
            
      public:
            virtual void Render(CCamera*){DEBUG("[CModel] Render should be called by inherited class!");}
            virtual bool Collided(CModel *){DEBUG("[CModel] Collided should be called by inherited class!"); return false;}
            virtual void Update(DWORD){DEBUG("[CModel] Update should be called by inherited class!");}
            virtual void Release(){DEBUG("[CModel] Release should be called by inherited class!");}
};

#endif //CHENEY_CMODEL_INCLUDED


==========================================================
CD3DXModel.h
==========================================================
#ifndef CHENEY_CD3DXMODEL_INCLUDED
#define CHENEY_CD3DXMODEL_INCLUDED

#include <d3dx9.h>
#include "Debug.h"
#include "CModel.h"
#include "CCamera.h"
#include "CMaterial.h"

class CD3DXModel : public CModel
{
      protected:
            LPD3DXMESH            m_pMesh;
            LPD3DXBUFFER      m_pAdjBuffer;
            LPD3DXBUFFER      m_pSubSetBuffer;
            LPD3DXBUFFER      m_pEffectBuffer;
            DWORD                  m_dwAttributes;
            CMaterial            **m_pMaterials;
            
      public:
            CD3DXModel();
            
            // CModel
            void Render(CCamera*);
            void Collided(){TRACE("[CD3DXModel] Collided not yet implemented");}
            void Update(DWORD elapsed){}
            void Release();
            
            // CModelManager access
            friend class CModelManager;
};


#endif //CHENEY_CD3DXMODEL_INCLUDED

==========================================================
CD3DXModel.cpp
==========================================================
#include "CD3DXModel.h"

//=============================================================================
// Constructor
//=============================================================================
CD3DXModel::CD3DXModel()
{
      // Init memebers
      //m_pD3DDevice = 0;
      m_pMesh = 0;
      m_pAdjBuffer = 0;
      m_pSubSetBuffer = 0;
      m_pEffectBuffer = 0;
      m_pMaterials = 0;
      m_dwAttributes = 0;
      //m_fSphereSize = 0.0f;
      //D3DXMatrixIdentity(&m_mtxWorld);
}



The error occurs in CD3DXModel.cpp just after the line "CD3DXModel::CD3DXModel()".

I also noticed that if I link the app without having CD3DXModel inherit from CModel it links without any problems... (but I need it to inherit)

Any ideas?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros