Build Failure On Desktop App

Komissarov Maxim 41 Reputation points
2022-09-25T12:13:49.563+00:00

I tried to create a simple desktop app for Windows in VS 2022. The debug configuration is set to Windows (/SUBSYSTEM:WINDOWS), but it still isn't able to build WinMain function.

Here's the code:

include "windows.h"

int WINAPI WinMain(
In HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
In LPSTR lpCmdLine,
In int nCmdShow
);

As a result, it gives me 2 errors.
1 - MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
2 - fatal error LNK1120: 1 unresolved externals

idk what to do with it

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,600 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,420 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RLWA32 40,286 Reputation points
    2022-09-25T13:07:07.19+00:00

    Go into your project properties and ensure that you have the correct setting for all platforms and configurations as shown below -

    244572-subsystem.png