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){
Message开发者_如何学编程Box(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 :)!
I had the same problem and was solved when I realized that I had forgotten to add the source
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.
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 -
精彩评论