写的一个windows的窗口出现如下错误,求大神解答
#include <windows.h> // include the basic windows header file
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
// create a "Hello World" message box using MessageBox()
MessageBox(NULL,
L"Hello World!",
L"Just another Hello World program!",
MB_ICONEXCLAMATION | MB_OK);
// return 0 to Windows
return 0;
}
错误:
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
1>D:\3dgame\3dgame\Debug\3dgame.exe : fatal error LNK1120: 1 个无法解析的外部命令
[解决办法]
建立工程的时候选择项目错了,应该是建立一个WIN32 Application 而不是我们平时写C++程序时候建立的那个WIN32 Console Application Win32 Application默认的程序入口是int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)这个,而Win32 Console Application 默认的程序入口才是main()
我也是一个菜鸟,以后还希望各位大虾们多多照顾哟!!!