Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help:How to Solve "Unresloved External Symbol" Error?

0 views
Skip to first unread message

Shahzad Malik

unread,
Jan 4, 1998, 3:00:00 AM1/4/98
to
Hi everybody:
Please help me in fixing the linker error given at the end. I have tried
all the options in the "Project Settings" but this error still
persists.In the "Build->Settings->General", I put "Use MFC in a Static
Library." In the "Build->Settings->C/C++ ->Code Generation->Use run-time
library", I have tried all the options beginning from leaving it blank
to Multithreaded, and Debug Multithreaded DLL. But nothing is removing
the error given below. Please tell me what else can I do to fix the
error. Your reply will be highly appreciated because I have been trying
to fix the problem for so many days.

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)

vcard.vcf

Jevgeni Astanovski

unread,
Jan 5, 1998, 3:00:00 AM1/5/98
to
> ---------------------------------------------------------------
>
> Name: vcard.vcf
> Part 1.2 Type: text/x-vcard
> Encoding: 7bit
> Description: Card for Shahzad Malik
I have a feeling that you have selected wrong project type when creating
a new project. I've got the same error and spent a whole day. Then found
that I have occasionally selected "CONSOLE APPLICATION" instead of
"application". I think that console application means something like a
32-bit programm that runs under DOS-prompt. And of course it requires
"main".
Hope it helps.
Eugen Astanovsky, Estonian Foreksbank.

Kedar R. Kelkar

unread,
Jan 5, 1998, 3:00:00 AM1/5/98
to

Hi Shahzad!

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

Chris Marriott

unread,
Jan 5, 1998, 3:00:00 AM1/5/98
to

In article <34AFFA70...@cunyvm.cuny.edu>, Shahzad Malik
<x6...@cunyvm.cuny.edu> writes

>libcmtd.lib(crt0.obj):error LNK2001: unresolved external symbol _main
>Test2.exe : fatal error LNK1120: 1 unresolved externals

"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

0 new messages