Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unresolved external symbol _main

Status
Not open for further replies.

jbs

Programmer
Feb 19, 2000
121
US
I purchased some materials to help show me how to make use of Microsoft Foundation Classes. The below program is actually one of the first example programs from the materials that I purchased. I haven't changed anything. Only problem is that after it compiles it won't link. I get the following error:

Several other programs that are provided in the materials make use of this 'working' program. I was hoping to spend some time today learning/experimenting with MFC.

The materials appear to be of very good quality. I suspect operator error on this one.....but's it's not jumping out at me and I'm too new to this environment.

Below is the error msg that I'm getting:

--------------------Configuration: basicMFC - Win32 Debug--------------------
Linking...
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/basicMFC.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

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



Under "project settings" within Visual Studio I've checked off "Use MFC in a Shared DLL" mode, etc. Seems like the main code is referencing an external symbol which it can't find. The name of the external symbol seems to be "_main".

I suspect this is a quick one....

help? The code is below.

thanks,
/Jerry


#include <afxwin.h>


class CMainWindow : public CFrameWnd {
public:
CMainWindow() {
Create(NULL,&quot;Basic MFC Application&quot;);
}

protected:
afx_msg void OnPaint() {
CPaintDC dc(this);
CRect r;
GetClientRect(&r);
dc.DrawText(&quot;Basic MFC Application&quot;,-1,&r,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
}
DECLARE_MESSAGE_MAP()
};

class CMFCApp : public CWinApp {
public:
virtual BOOL InitInstance() {
m_pMainWnd=new CMainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
};


BEGIN_MESSAGE_MAP(CMainWindow,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

CMFCApp app;

 
FYI. I got the program to work by reloading the original files, opening the .dsw file, linking, and then ran the file. It worked fine.

There are no differences between the two source files.....none.

I'm moving on in the course materials....but this one seems strange to me. Any obvious ideas? Does this typically happen with Visual C++ w/MFC (...hope not).

/jerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top