Reputation: 13620
The simple code fails:
#include <Windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
MessageBox(NULL, L"Hello World!", L"Just another Hello World program!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
Errors:
Error 1 error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup ... Projects\DX11_3\DX11_3\MSVCRTD.lib(crtexe.obj) DX11_3
Error 2 error LNK1120: 1 unresolved externals ... Projects\DX11_3\Debug\DX11_3.exe 1 1 DX11_3
What could be wrong? I've downloaded and installed Windows SDK, added det include folder to the project.
Upvotes: 2
Views: 1245
Reputation: 23303
you are compiling your application as a "Console Application", so Visual Studio tries to find an entry point named main()
. but your code defines a "GUI Application" with an entry point named WinMain()
.
you should edit your project settings and set the application type to "Console application" in the Linker settings.
Upvotes: 1
Reputation: 214810
Strictly and formally speaking, your program doesn't contain a function named main, so it isn't valid C++.
To enable non-standard extensions like WinMain, you will have to make sure you are creating a Windows project, or that the compiler options are set to compile a Windows program.
Upvotes: 1
Reputation: 13993
The program's entry point is where execution starts at. For a console application, this defaults to main
. For a Windows application with no console, this defaults to WinMain
.
The linker is searching for main
, most likely because you created a console application. Go into your project settings and change the subsystem to Windows. You can find this option in Configuration Settings -> Linker -> System
Upvotes: 2