a question in learning the Programing Windows with MFC
-
Hi, I am reading the book Programing Windows with MFC,but the example(The Hello Application) that it gave in chapter 1 cannot be compiled in the vc++ 6,it shows the informations below: nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Hello.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. Did the codes the book gave wrong? Or I should do anymore? the codes are listed below: Hello.h class CMyApp : public CWinApp { public: virtual BOOL InitInstance (); }; class CMainWindow : public CFrameWnd { public: CMainWindow (); protected: afx_msg void OnPaint (); DECLARE_MESSAGE_MAP () }; Hello.cpp #include #include "Hello.h" CMyApp myApp; ///////////////////////////////////////////////////////////////////////// // CMyApp member functions BOOL CMyApp::InitInstance () { m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow (m_nCmdShow); m_pMainWnd->UpdateWindow (); return TRUE; } ///////////////////////////////////////////////////////////////////////// // CMainWindow message map and member functions BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd) ON_WM_PAINT () END_MESSAGE_MAP () CMainWindow::CMainWindow () { Create (NULL, _T ("The Hello Application")); } void CMainWindow::OnPaint () { CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } //I am sorry to interrupt you but I am a beginner,so if you know the answer,please tell me,thanks. YES, I am here.
-
Hi, I am reading the book Programing Windows with MFC,but the example(The Hello Application) that it gave in chapter 1 cannot be compiled in the vc++ 6,it shows the informations below: nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Hello.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. Did the codes the book gave wrong? Or I should do anymore? the codes are listed below: Hello.h class CMyApp : public CWinApp { public: virtual BOOL InitInstance (); }; class CMainWindow : public CFrameWnd { public: CMainWindow (); protected: afx_msg void OnPaint (); DECLARE_MESSAGE_MAP () }; Hello.cpp #include #include "Hello.h" CMyApp myApp; ///////////////////////////////////////////////////////////////////////// // CMyApp member functions BOOL CMyApp::InitInstance () { m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow (m_nCmdShow); m_pMainWnd->UpdateWindow (); return TRUE; } ///////////////////////////////////////////////////////////////////////// // CMainWindow message map and member functions BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd) ON_WM_PAINT () END_MESSAGE_MAP () CMainWindow::CMainWindow () { Create (NULL, _T ("The Hello Application")); } void CMainWindow::OnPaint () { CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } //I am sorry to interrupt you but I am a beginner,so if you know the answer,please tell me,thanks. YES, I am here.
You need to link with the MFC library [either statically or dynamically] Nish
My miniputt high is now 29 I do not think I can improve on that My temperament won't hold www.busterboy.org
-
Hi, I am reading the book Programing Windows with MFC,but the example(The Hello Application) that it gave in chapter 1 cannot be compiled in the vc++ 6,it shows the informations below: nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Hello.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. Did the codes the book gave wrong? Or I should do anymore? the codes are listed below: Hello.h class CMyApp : public CWinApp { public: virtual BOOL InitInstance (); }; class CMainWindow : public CFrameWnd { public: CMainWindow (); protected: afx_msg void OnPaint (); DECLARE_MESSAGE_MAP () }; Hello.cpp #include #include "Hello.h" CMyApp myApp; ///////////////////////////////////////////////////////////////////////// // CMyApp member functions BOOL CMyApp::InitInstance () { m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow (m_nCmdShow); m_pMainWnd->UpdateWindow (); return TRUE; } ///////////////////////////////////////////////////////////////////////// // CMainWindow message map and member functions BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd) ON_WM_PAINT () END_MESSAGE_MAP () CMainWindow::CMainWindow () { Create (NULL, _T ("The Hello Application")); } void CMainWindow::OnPaint () { CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } //I am sorry to interrupt you but I am a beginner,so if you know the answer,please tell me,thanks. YES, I am here.
If you're writing this from a blank project, you need to read carefully how to set it up. I've learned what all the bits the wizard gives me do, but I've never started a project except through the wizard - it just makes more sense to me to let the compiler generate boiler plate code, although, as I say, I've also had a good dig through it and can do a lot of the wizard stuff by hand if I want/need to. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
-
If you're writing this from a blank project, you need to read carefully how to set it up. I've learned what all the bits the wizard gives me do, but I've never started a project except through the wizard - it just makes more sense to me to let the compiler generate boiler plate code, although, as I say, I've also had a good dig through it and can do a lot of the wizard stuff by hand if I want/need to. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
Christian Graus wrote: If you're writing this from a blank project, you need to read carefully how to set it up There is not much to setting it up actually 1. Include the MFC headers 2. Link with MFC [statically or dynamically] That's all... Nish
My miniputt high is now 29 I do not think I can improve on that My temperament won't hold www.busterboy.org
-
Christian Graus wrote: If you're writing this from a blank project, you need to read carefully how to set it up There is not much to setting it up actually 1. Include the MFC headers 2. Link with MFC [statically or dynamically] That's all... Nish
My miniputt high is now 29 I do not think I can improve on that My temperament won't hold www.busterboy.org
Fair enough, but obviously the book would have told him how to do that and he's missed it. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
-
Fair enough, but obviously the book would have told him how to do that and he's missed it. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
Christian Graus wrote: Fair enough, but obviously the book would have told him how to do that and he's missed it. Yeah, that sounds highly probable. Nish
My miniputt high is now 29 I do not think I can improve on that My temperament won't hold www.busterboy.org
-
Hi, I am reading the book Programing Windows with MFC,but the example(The Hello Application) that it gave in chapter 1 cannot be compiled in the vc++ 6,it shows the informations below: nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Hello.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. Did the codes the book gave wrong? Or I should do anymore? the codes are listed below: Hello.h class CMyApp : public CWinApp { public: virtual BOOL InitInstance (); }; class CMainWindow : public CFrameWnd { public: CMainWindow (); protected: afx_msg void OnPaint (); DECLARE_MESSAGE_MAP () }; Hello.cpp #include #include "Hello.h" CMyApp myApp; ///////////////////////////////////////////////////////////////////////// // CMyApp member functions BOOL CMyApp::InitInstance () { m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow (m_nCmdShow); m_pMainWnd->UpdateWindow (); return TRUE; } ///////////////////////////////////////////////////////////////////////// // CMainWindow message map and member functions BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd) ON_WM_PAINT () END_MESSAGE_MAP () CMainWindow::CMainWindow () { Create (NULL, _T ("The Hello Application")); } void CMainWindow::OnPaint () { CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } //I am sorry to interrupt you but I am a beginner,so if you know the answer,please tell me,thanks. YES, I am here.
The problem is your project settings are set to link with the single-threaded C runtime. MFC requires the multi-threaded version (as indicated by the fact that it's trying to find thread-related functions). Click Project->Settings, C++ tab, Code Generation category, and set the Use runtime library setting to Debug Multithreaded (for the debug config) or Multithreaded (for release). --Mike-- Rollin' in my 5.0 With the rag-top down so my hair can blow. My really out-of-date homepage Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan and Jamie Salé.
-
Hi, I am reading the book Programing Windows with MFC,but the example(The Hello Application) that it gave in chapter 1 cannot be compiled in the vc++ 6,it shows the informations below: nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Hello.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. Did the codes the book gave wrong? Or I should do anymore? the codes are listed below: Hello.h class CMyApp : public CWinApp { public: virtual BOOL InitInstance (); }; class CMainWindow : public CFrameWnd { public: CMainWindow (); protected: afx_msg void OnPaint (); DECLARE_MESSAGE_MAP () }; Hello.cpp #include #include "Hello.h" CMyApp myApp; ///////////////////////////////////////////////////////////////////////// // CMyApp member functions BOOL CMyApp::InitInstance () { m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow (m_nCmdShow); m_pMainWnd->UpdateWindow (); return TRUE; } ///////////////////////////////////////////////////////////////////////// // CMainWindow message map and member functions BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd) ON_WM_PAINT () END_MESSAGE_MAP () CMainWindow::CMainWindow () { Create (NULL, _T ("The Hello Application")); } void CMainWindow::OnPaint () { CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } //I am sorry to interrupt you but I am a beginner,so if you know the answer,please tell me,thanks. YES, I am here.