MFC error LNK2019

Started by
6 comments, last by Sfpiano 19 years, 7 months ago
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]
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Advertisement
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.
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
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)// Attributespublic:	CDirect3DMFCDoc* GetDocument();// Operationspublic:// 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// Implementationpublic:	virtual ~CDirect3DMFCView();#ifdef _DEBUG	virtual void AssertValid() const;	virtual void Dump(CDumpContext& dc) const;#endifpublic:// Generated message map functionsprotected:	//{{AFX_MSG(CDirect3DMFCView)	afx_msg void ...	//}}AFX_MSG	DECLARE_MESSAGE_MAP()private:	D3DXVECTOR3 vStart, vEnd;};#ifndef _DEBUG  // debug version in Direct3DMFCView.cppinline CDirect3DMFCDoc* CDirect3DMFCView::GetDocument()   { return (CDirect3DMFCDoc*)m_pDocument; }#endif#endif // !defined(AFX_DIRECT3DMFCVIEW_H__59C333F5_2B1E_4440_B175_D2C265A805D8__INCLUDED_)
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
What is the exact error that you get?
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)
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Hello

It looks that you forgot to IMPLEMENT_DYNCREATE() in your .cpp file. DECLARE_DYNCREATE() cannot do all the job for you :)

HTH,
Nope.

#include "stdafx.h"#include "Viewer.h"#include "Orthographic.h"#include "CDXWnd.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// COrthographicIMPLEMENT_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;
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

This topic is closed to new replies.

Advertisement