Thanks
------------------------------------------
#include <afxwin.h>
class CMainWin : public CFrameWnd
{
public:
CMainWin();
DECLARE_MESSAGE_MAP()
};
CMainWin::CMainWin()
{
Create(NULL, "An MFC Application Skeleton");
}
class CApp : public CWinApp
{
public:
BOOL InitInstance();
};
BOOL CApp::InitInstance()
{
m_pMainWnd = new CMainWin;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd)
END_MESSAGE_MAP()
CApp App;
--------------------Configuration: Test2 - Win32
Release--------------Compiling...
Test2.cpp
Linking...
libcmtd.lib(crt0.obj):error LNK2001: unresolved external symbol _main
Test2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Test2.exe - 2 error(s), 0 warning(s)
Whenever you create a new file, type some C++ code in that and try to build
the app, A default workspace is created for you. This default workspace
happens to create an application that's console based. This application is
not a Windows GUI application. Rather, it's not a Windows application at
all. A Windows application's entry point is WinMain, whereas console (that's
what we used to call DOS before) application's entry point is main. If you
specify the application as a console application, there has to be a main
function, which will be marked as entry point of the application. Therefore,
a linker looks for a function 'main' and doesn't find it and complains.
There is an argument to the linker that specifies the subsystem for which
the application is being generated. That's called 'subsystem'. You have to
set this parameter to ' /subsystem:windows' so that it becomes an
application for Windows. A true Windows application, which starts with
WinMain. WinMain is supplied by MFC code. So linker finds it and it gets
through.
To set this, go to Project|Settings|Link and in the text box at the bottom
of the dialog, named Project Options, type the string '/subsystem:windows'.
This should solve the problem.
I hope that's what you need and this will get you going. If you still have
any problem, feel free to mail me. I would be pleased to help.
Kedar
"main" is the name of the entry point for a *console* application. Your
program is (presumably) a GUI application. You need to tell the linker
that it should create a GUI application rather than a console
application; I'll leave it up to you to research how to do that!
Chris
----------------------------------------------------------------
Chris Marriott, Microsoft Certified Solution Developer.
SkyMap Software, U.K. e-mail: ch...@skymap.com
Visit our web site at http://www.skymap.com