Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. a question in learning the Programing Windows with MFC

a question in learning the Programing Windows with MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++learningquestiondebugginghelp
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Angel Kid
    wrote on last edited by
    #1

    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.

    N C M A 4 Replies Last reply
    0
    • A Angel Kid

      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.

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A Angel Kid

        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.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • C Christian Graus

          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

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          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

          C 1 Reply Last reply
          0
          • N Nish Nishant

            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

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            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

            N 1 Reply Last reply
            0
            • C Christian Graus

              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

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • A Angel Kid

                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.

                M Offline
                M Offline
                Michael Dunn
                wrote on last edited by
                #7

                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é.

                1 Reply Last reply
                0
                • A Angel Kid

                  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.

                  A Offline
                  A Offline
                  Angel Kid
                  wrote on last edited by
                  #8

                  thanks everybody answered this question. yes,in the end of the chapter,the writer gave the step on how to build it.I have not read it.now everything is ok,thank you. YES, I am here.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups