12

I have created new emty project. Then have added cpp and header hello world files taken from Jeff Prosise 'Programming Windows with MFC' book. Have set Use of MFC to Use MFC in a Shared DLL

Got error entry point must be defined How to fix this problem?

CPP:

#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 ()
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);
}

H:

class CMyApp : public CWinApp
{
public:
    virtual BOOL InitInstance ();
};

class CMainWindow : public CFrameWnd
{
public:
    CMainWindow ();

protected:
    afx_msg void OnPaint ();
    DECLARE_MESSAGE_MAP ()
};
vico
  • 17,051
  • 45
  • 159
  • 315

1 Answers1

11

You need to tell compiler to use WinMain (which is provided by MFC: http://msdn.microsoft.com/en-us/library/akdx0603.aspx) instead of main as an entry point.

Right click project, select Properties, and navigate to Linker -> System -> SubSystem. Change SubSystem to Windows.

Nemanja Boric
  • 21,627
  • 6
  • 67
  • 91