LINK : error LNK2001: unresolved external symbol _main

Posted by Fender on Sun 02 Nov 2003 04:38 PM — 6 posts, 20,215 views.

#0
I get that error:

LINK : error LNK2001: unresolved external symbol _main

after all of the hours and hours of going through everything and making it so that it will all compile in MSVC++ 6.0

and this is the last one I will have, and its the only one i cant seem to get past.

can somebody help me out with this?

On msdn.com it says that error means that it cant find main(), but its in webserver.c......why doesnt it find it?

It is also found in numerous other files such as services.c, webclient.c,
Amended on Sun 02 Nov 2003 04:44 PM by Fender
USA #1
You can't have more than one main. If you truly do have multiple mains declared, then that's most likely what's confusing the compiler.

Check the macroes and #ifdefs to make sure that the mains aren't being "deactivated" or anything... if I remember correctly, there is quite different behavior for the Unix main and the Windows main. Maybe even the Windows version implements WinMain, which is the entry point for Win32 applications (as opposed to console applications.)
#2
well i found main function in service.c, but for some reason the linker doesnt want to find it


and yes msvc++ supports winmain, but smaug doesnt.

any other ideas on what i should do?
USA #3
You said that you found multiple mains... you need to look at whether or not they're being seen by the compiler - e.g., the preprocessor definitions like #ifdef WIN32 - and then determine how to fix it if they're not - or if multiple ones are being seen.

What do you mean, SMAUG doesn't support WinMain? SMAUG doesn't care about that. That's just the entry point function for your application, and the compiler cares... not SMAUG. Of course, if SMAUG assumes that all your initialization is in main, not WinMain, then yes, you have to call that code somehow, but that's a compiler issue, not a SMAUG issue.
USA #4
webserver.c and webclient.c are probably part of the IMC2 code that was originally packaged with Smaug. You should be able to safely remove those as they are ancient and probably of little value.
Australia Forum Administrator #5
service.c may not be in your project.

It doesn't help to have main in your file if it isn't in the project.

And yes, main is the entry point for a console app.