OpenGL tutorial error MSVCTRD.lib(exe_winmain.obj): LNK2019

Willard 45 Reputation points
2023-03-20T21:17:07.23+00:00

Attempting to follow a tutorial on opengl, but running into

MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

The tutorial simply wants to link the necessary files before proceeding (and is linked below) and tests it. I have looked for similar problems which mention setting sub systems to windows, but the problem persists and I haven't found anything to explain what the error is aside from being a linking error.

https://learnopengl.com/Getting-started/Creating-a-window

I have also attempted to remake the project in visual studio with "windows desktop application" but same result. I learned most of C++ and went straight to this so my knowledge of visual studio or opengl is limited.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,631 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Willard 45 Reputation points
    2023-03-22T05:23:44.6133333+00:00

    After some tampering with a later tutorial I simply added

    int WinMain() { return 0;}

    to the source code and all errors regarding LNK2019 are gone. I suspect the error will show if there is no WinMain or main (depending on subsystem) within the source.cpp for the compiler to look at. This did not occur in VS2019, but regardless thank you @RLWA32 for helping.

    1 person found this answer helpful.