Rolilink
Rolilink

Reputation: 443

LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup

i am learning c++ for game dev i am reading a book and usin win32 api so i tried to compile a test of my program

 #include <windows.h>

        int WINAPI WinMain(HINSTANCE hInsance,HINSTANCE hPrevInstance,PSTR cmdLine,int showCmd){
            MessageBox(0,"First Win32 Program","Window Tittle",MB_OK);
            }

i am getting:

LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup

i am new in win32 programming so i dont know where is the error i am using windows7 thnx :)!

Upvotes: 1

Views: 8189

Answers (3)

Quarian
Quarian

Reputation: 31

I had the same problem and was solved when I realized that I had forgotten to add the source

Upvotes: 3

Ben Voigt
Ben Voigt

Reputation: 283614

You can either use /ENTRY:WinMain to override the default name, or compile with /MT so the compiler will mark the object files in such a way that the linker grabs the runtime library (which provides an entry point).

The runtime library entry point does some nice things like run global constructors set up a global exception handler so you get a dialog box in case of uncaught exceptions, but nothing it does is absolutely necessary.


NOTE: If you don't use the library entry point, no arguments are available. You have to use the OS functions such as GetCurrentProcess and GetCommandLine and GetStartupInfo instead to get the information normally available as WinMain arguments. You weren't using any of that anyway. But think twice about using your own entry point, a lot of stuff depends on the library initialization and you'd better be very sure you aren't using it.

Upvotes: 1

Jeff
Jeff

Reputation: 2009

You really want to look into XNA for game dev. And for your first app - let the VC++ IDE do the heavy lifting. Choose New Project, Console App, then printf "Hello World" - all the defaults will be set for you -

Upvotes: -2

Related Questions