Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Entry point not defined?

Whenever I go to build a .cpp file in Microsoft Visual Studio 2005 Professional, I recieve a "fatal error LNK1561: entry point must be defined" error. I have no clue what this means..does anyone know?

My main function looks like this:

int main(int argc, char *argv[ ], char *envp[ ])
{
// Initialize variables
char cDummy;

introduce_program();
cin >> cDummy;

return 0;
}
[438 byte] By [Dark Rain] at [2007-11-11 10:13:46]
# 1 Re: Entry point not defined?
yes, it means that your program doesn't have main().
Danny at 2007-11-11 20:59:12 >
# 2 Re: Entry point not defined?
It seems I was actually using a wrong project type. The first time I just used an empty C++ project, which VC++ doesn't like. The second time I used a console app type, and that seemed to compile fine.

Then VS was complaining about how it couldn't spawn cmd.exe (as if that's my problem :D ), not sure if anyone has had this issue but if you have add these entries to your Tools > Options > Projects and Solutions > VC++ Directories tab:

$(SystemRoot)
$(SystemRoot)\System32\wbem
$(SystemRoot)\System32

Getting to know an environment can be a pain sometimes :)
Dark Rain at 2007-11-11 21:00:12 >
# 3 Re: Entry point not defined?
An entry point is either main(), in a console app, or if you're creating a dll, some matching dll declarations. If you're going for standard C++ type of applications, you should always use a Console Application setting. Also, it's best to remove the command line arguments. The code wizard automatically inserts the int argc, char *argv[ ], char *envp[ ] in main() but if you're not using these variables (and many programs don't), get rid of them.
Danny at 2007-11-11 21:01:17 >
# 4 Re: Entry point not defined?
you can define the main in the project settings. It is normally not just main in mfc generated apps, but often some other name with main in it (wmmain, _main, etc).
jonnin at 2007-11-11 21:02:17 >