Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot compile Win32 application in Visual Studio

Tags:

c++

winapi

It's my first time playing around with the Win32 API. What I'm trying to do is to make a simple window. I'm writing the code in Visual Studio 2019 on Windows 10 with all the required things installed to work with C++. The problem I'm having is that none of the code I found from searching around the web has worked, even just the simple wWinMain. Is there something I am doing completely wrong? or is there something special with VS2019 or Windows 10 in general?

I tried running the code from a bunch of different sources. Also tried manually running the code with the cl compiler from the terminal.

Code:

#include <windows.h>

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) {
    /* Some Code*/
    return 0;
}

Errors:

Warning C28251 Inconsistent annotation for 'wWinMain': this instance has no annotations.
Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)  
Error LNK1120 1 unresolved externals
like image 379
lilBunnyRabbit Avatar asked Oct 27 '25 03:10

lilBunnyRabbit


1 Answers

Change your application from "Console" to "Windows" Right click on project -> Properties -> Linker options -> System.

enter image description here

like image 151
Michael Chourdakis Avatar answered Oct 29 '25 18:10

Michael Chourdakis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!