compiling with vc++.NET

This is a discussion on compiling with vc++.NET within the C++ Programming forums, part of the General Programming Boards category; I've got "Programming Windows with MFC, Second Edition" book, I'm trying to compile its first example with VC++.NET but I'm ...

  1. #1

    Angry compiling with vc++.NET

    I've got "Programming Windows with MFC, Second Edition" book, I'm trying to compile its first example with VC++.NET but I'm getting a linker error:

    <li>MFC error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)</li>
    <li>MFC error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTR IBUTES@@@Z)</li>
    <li>MFC error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup</li>
    <li>MFC fatal error LNK1120: 3 unresolved externals</li>

    The program source code:

    class CMyApp : public CWinApp
        virtual BOOL InitInstance ();
    class CMainWindow : public CFrameWnd
        CMainWindow ();
        afx_msg void OnPaint ();

    #include <afxwin.h>
    #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 ()
    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,

    Please help

  2. #2
    Should I add an iclude statement or something?

  3. #3
    Registered User fletch's Avatar
    Join Date
    Jul 2002
    I'm going through the same book now.

    I'm not familiar with MSVC++ .NET (I use MSVC++ 6.0), but I've found that when I get a list of indecipherable error messages, it's usually because I forgot to set the Project Settings to 'Use MFC'

    On MSVC++ 6.0 it's listed under Settings on the Project menu (Alt-F7). On the General tab there's a drop down box entitled Microsoft Foundation Classes. I don't know if there's an equivalent to this with .NET, but it's worth looking at I guess.

    "Logic is the art of going wrong with confidence."
    Morris Kline

  4. #4
    Thanks a lot for your response, in fact I have VC++ 6 too, I was trying to compile it using my friend's compiler, because mine gave all kinds of error messages.
    Any way, using VC++ 6, and using your tip, the number of error messages was reduced to 2:

    -------------------Configuration: test - Win32 Debug--------------------
    msvcrtd.lib(crtexe.obj) : error LNK2001: unresolved external symbol _main
    Debug/test.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    test.exe - 2 error(s), 0 warning(s)

    Please help! I've been reading for one week, and I couldn't compile one program till now!

  5. #5
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    The first problem you mentioned has been solved. Indeed those errormessages mean you have to set your project settings to "Use MFC statically/dynamically".

    The second problem is you chose the wrong project type. Copy all your code, open up a new "Win32" Project ( not console ) and paste all your code. This should compile.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  6. #6

    Problems solved, thank you guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  2. vc express compiling???
    By code2d in forum C++ Programming
    Replies: 1
    Last Post: 12-06-2006, 01:14 PM
  3. Difference in MSVC 6 & MS VC .Net
    By passionate_guy in forum C Programming
    Replies: 1
    Last Post: 01-23-2006, 06:39 AM
  4. Porting code from VC++6 to VC .NET??
    By dug in forum C++ Programming
    Replies: 10
    Last Post: 01-31-2005, 11:42 AM
  5. Visual J#
    By mfc2themax in forum A Brief History of
    Replies: 0
    Last Post: 10-08-2001, 03:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21