VC++报错: LNK2019 unresolved external symbol main referenced in function “int __cdecl invoke_main(v

学习Windows API编程,跑Hello World报错:

 LNK2019    unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)    WinAPI_demo    C:\Users\77375\source\repos\WinAPI_demo\WinAPI_demo\MSVCRTD.lib(exe_main.obj)    1   

代码很简单:

#include 

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpcmdLine, int nCmdShow)
{
	MessageBox(NULL, TEXT("Hello Worlds"), TEXT("My First Application"), MB_OK);
	return 0;
}

网上查询得知,是Linker的设置有问题:

项目右击 > 属性 > Linker > System > SubSystem,

当前设成了CONSOLE,改成Windows即可。

VC++报错: LNK2019 unresolved external symbol main referenced in function “int __cdecl invoke_main(v_第1张图片

重新build成功,可以运行:

VC++报错: LNK2019 unresolved external symbol main referenced in function “int __cdecl invoke_main(v_第2张图片

参考:"Unresolved external "int __cdecl invoke_main(void)" after VS2017 15.6.1 update" -- Part 2 - Microsoft Q&A

你可能感兴趣的:(Windows,API,Windows,API)