Sign in to follow this  
Sfpiano

MFC error LNK2019

Recommended Posts

When I try to call RUNTIME_CLASS(Class) in MainFrm, I get the 2019 error; specifically I'm doing it when setting up the view of a splitter window. Here's the class:
class COrthographic : public CView, public Graphics
{
protected:
	COrthographic();
	DECLARE_DYNCREATE(COrthographic)

// Attributes
public:
	int	  m_lastMouseX,
		  m_lastMouseY;
	float m_zoom,
		  m_xpos,
		  m_ypos;

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(COrthographic)
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~COrthographic();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
protected:
	//{{AFX_MSG(COrthographic)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

I checked, and I'm using MFC as a shared dll, so that's not the problem. [Edited by - Sfpiano on September 1, 2004 5:43:57 PM]

Share this post


Link to post
Share on other sites
Quote:
MSDN
Only CObject-derived classes declared with DECLARE_DYNAMIC, DECLARE_DYNCREATE, or DECLARE_SERIAL will return pointers to a CRuntimeClass structure.

Maybe you forgot to derive from CObject in Graphics or in one of its base classes.

Share this post


Link to post
Share on other sites
Im guessing that COrthographic is ment to be one of the views of the splitter window, and is passed to CSplitterWnd when you call CreateView(...)?

Make sure COrthographic is derived from CView, otherwise it will not work. That may or may not be your problem, I cant tell anything else from the information you have posted

Spree

Share this post


Link to post
Share on other sites
The annoying thing is I have a class that (to me) appears exactly the same as the ortho class, except that this one works with a runtime_class call:


class CDirect3DMFCView : public CView, public Graphics
{
protected: // create from serialization only
CDirect3DMFCView();
DECLARE_DYNCREATE(CDirect3DMFCView)

// Attributes
public:
CDirect3DMFCDoc* GetDocument();

// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDirect3DMFCView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnInitialUpdate();

protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CDirect3DMFCView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

public:

// Generated message map functions
protected:
//{{AFX_MSG(CDirect3DMFCView)
afx_msg void ...
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
D3DXVECTOR3 vStart, vEnd;
};

#ifndef _DEBUG // debug version in Direct3DMFCView.cpp
inline CDirect3DMFCDoc* CDirect3DMFCView::GetDocument()
{ return (CDirect3DMFCDoc*)m_pDocument; }
#endif

#endif // !defined(AFX_DIRECT3DMFCVIEW_H__59C333F5_2B1E_4440_B175_D2C265A805D8__INCLUDED_)

Share this post


Link to post
Share on other sites
Direct3DMFC error LNK2019: unresolved external symbol "public: static struct CRuntimeClass * __stdcall COrthographic::GetThisClass(void)" (?GetThisClass@CTop@@SGPAUCRuntimeClass@@XZ) referenced in function "protected: virtual int __thiscall CMainFrame::OnCreateClient(struct tagCREATESTRUCTA *,struct CCreateContext *)" (?OnCreateClient@CMainFrame@@MAEHPAUtagCREATESTRUCTA@@PAUCCreateContext@@@Z)

Share this post


Link to post
Share on other sites
Nope.


#include "stdafx.h"
#include "Viewer.h"
#include "Orthographic.h"
#include "CDXWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COrthographic

IMPLEMENT_DYNCREATE(COrthographic, CDXWnd)


My big problem is when I try to get all the split windows to be different perspectives of the same scene, as opposed to being completely independent, because then I just call this code which works:


//calculate client size
CRect cr;
GetWindowRect( &cr );

// Create the main splitter with 1 row and 2 columns
if ( !m_mainSplitter.CreateStatic( this, 1, 2 ) )
{
MessageBox( "Error setting up m_mainSplitter", "ERROR", MB_OK | MB_ICONERROR );
return FALSE;
}

// The views for each pane must be created
if ( !m_mainSplitter.CreateView( 0, 0, RUNTIME_CLASS(CDirect3DMFCView),
CSize(cr.Width()/2, cr.Height()), pContext ) )
{
MessageBox( "Error setting up splitter view", "ERROR", MB_OK | MB_ICONERROR );
return FALSE;
}

if ( !m_mainSplitter.CreateView( 0, 1, RUNTIME_CLASS(CDirect3DMFCView),
CSize(cr.Width()/2, cr.Height()), pContext ) )
{
MessageBox( "Error setting up splitter view", "ERROR", MB_OK | MB_ICONERROR );
return FALSE;
}

//change flag to show splitter created
m_initSplitters = true;

//return TRUE instead of the parent method since that would
//not show our window
return TRUE;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this