编译时出错:unresolved external symbol _main
          为什么?

解决方案 »

  1.   

    appwizrd时是不是选择了win32 application啊。
    在project->setting里把c/c++-> project options里的win32改成console.
      

  2.   

    源程序如下:
    #include "afxwin.h"
    class CMyApp : public CWinApp
    {
    public:
    virtual BOOL InitInstance();
    };
    class CMainFrame : public CFrameWnd
    {};
    CMyApp myApp;BOOL CMyApp::InitInstance()
    {
    m_pMainWnd= new CMainFrame;
    ((CMainFrame*)m_pMainWnd)->Create(NULL,"The MFC Application");
    m_pMainWnd->ShowWindow(m_nCmdShow);  
        return TRUE;
    }
    在project->setting里把c/c++-> project options里的win32改成console之后,错误更多:
    --------------------Configuration: g - Win32 Debug--------------------
    Compiling...
    g.cpp
    Linking...
    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/g.exe : fatal error LNK1120: 3 unresolved externals
    Error executing link.exe.g.exe - 4 error(s), 0 warning(s)