During the proccess of linking the LNK2001 error happens:
- LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall CChildView::GetRuntimeClass(void)const " (?GetRuntimeClass@CChildView@@UBEPAUCRuntimeClass@@XZ)
Why would this be?
Here is the relevant code in the header:
class CChildView :public CDialog
{
DECLARE_DYNAMIC(CChildView)
public:
CChildView();
~CChildView();
afx_msg void OnPaint();
afx_msg void OnLevelProf();
afx_msg void OnLevelAmat();
afx_msg void OnLevelBeg();
afx_msg void OnStepC();
void new_game();
//void CloseWindow();
BOOL PreCreateWindow(CREATESTRUCT& cs);
int end_analyze();
void ii();
unsigned long calculate(int id, int x, int y);
afx_msg void OnNewGame();
//void Invalidate();
afx_msg void OnX1010();
afx_msg void OnX1919();
afx_msg void OnX3030();
afx_msg void OnX5050();
afx_msg void OnX100100();
//MessageBoxW();
void resize_window();
afx_msg void OnLButtonDown(UINT, CPoint xy);
//void GetWindowRect(RECT);
//int MessageBoxW();
void OnStepH();
void set_chеcked_menu(unsigned int old_id, unsigned int new_id);
DECLARE_MESSAGE_MAP()
};
And the part of .cpp file:
//IMPLEMENT_DYNAMIC(CChildView, CWnd)//!without this - doesn`t compiles. With - //runtime failure
BEGIN_MESSAGE_MAP(CChildView, CWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
.....
END_MESSAGE_MAP()
But during the execution of my programm (if implement_dynamicaly is uncommented) it fails in AfxWinMain function on the line:
if (!pThread->InitInstance())
My other classes don't explicitly define them and they don't have errors. Here is somethink like this, but it didn`t help me. MFC dlg class link errors for MyClass::GetMessageMap() and MyClass::GetRuntimeClass (MSVC 2008)
DECLARE_DYNAMIC
you need theIMPLEMENT_DYNAMIC
. Your question is not about linking. It is about run-time behavior of your program, and you have provided next to no information about that. Fire up your debugger. Find out what's going on. – Cheers and hth. - AlfCDialog
. But then you switch toCWnd
inIMPLEMENT_DYNAMIC
and inBEGIN_MESSAGE_MAP
. From the look of your declarations I don't know if that's meant to beCDialog
orCWnd
orCView
. For the time being comment outDECLARE_DYNAMIC
. Also you should explain roughly what sort of view model you are after (dialog or multi-document view or single-document...) – Barmak Shemirani