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 in visual c++

Status
Not open for further replies.

mattholomew

Programmer
Oct 10, 2000
4
0
0
US
Hi. I'm doing some windows game programming, but I just switched over from Borland C++ 4.5 to Visual C++ 4.0. With this new compiler, it is not accepting WinMain, apparently. This is the main() function for windows. If anyone could tell me why, I would appreciate it. The specific error is 'unresolved external symbol _main.' It is a linking error. Now, the borland compiler book has a list of errors in the back. This one does not. What's up with that? It sure would be helpful, seeing as I don't know an unresolved external symbol error from A DEAD MUPPET. Yes, it's that bad. Here is my little windows program:


// PROG3_2.CPP - A simple message box
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>

// main entry point for all windows programs
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
// call message box api
MessageBox(NULL, &quot;What's up world!&quot;,
&quot;My First Windows Program&quot;,MB_OK);

// exit program
return(0);
} // end WinMain

I'd appreciate some help, thanks a lot!
Mattholomew

[sig][/sig]
 
I don`t know how is that with VC40, but probably you need check a settings and project properties, maybe your compiler think, that this is a dos program.
Actually - make your new VC project and check his settings ...
 
I had that exact same problem! Right out of the box I'm dead in the water. I'm surprised everyone doesn't have it. My VC++6.0 also didn't seem to come with an MSDN library, so I can't get online help. I've tinkered with the settings to no avail. It wants to treat my prog as a non-windowed app even though I specified to use the MFC libraries. Can't it figure that out?
 
I had this problem too, but I managed to resolve it.
Here's how.

Type up your program (with WinMain())...
Create a new project in VC. Choose Win32 Application.
Type a name for the project and press next. Then choose &quot;An empty project&quot; and click Finish. When the project is finished and loaded, right click on your source file and tell it to add to project and then choose your new project.

This is the only way I have gotten it to work, but it seems to work fine for me now... Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top