I've deleted the _tmain()
method which the IDE generated because I find no sense having two entry points after adding my WinMain
entry. And yes, this is my first ever C++ application and I am a newbie, but please be nice.
So that's all I got:
// Included headers:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
// Shortened namespaces:
using namespace std;
// The main entry of the application:
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;
}
// End of file.
When I try to build and run I get this error:
error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
error LNK1120: 1 unresolved externals
I realise the entry point is missing, But where can I set WinMain
as the entry point? I just took a look in the properties of the project itself and found nothing.
Note that I've started the project as a console application, But now I am trying to turn it into a regualr windows application.
Thanks.
WinMain
isn't the actual entry point from the operating system's point of view. It's called by the runtime environment (or RT, as in CRT), which needs to be initialized (or started up, as in Startup). So, yeah, that_tmain
is there for a reason. It's the actual entry point.WinMain
is only an entry point 'by convention'. – Tensile_tmain
method and everything works fine, But I really have no idea where from to get the parameters forWinMain
, So I just call it from_tmain
with NULLs. Is that really supposed to be like that? – Kynewulf