c++ – Qt Visual Studio Tools update causes a linker error


The code in my codebase has been compiling for years. I just upgraded Microsoft Visual Studio Professional 2019 to version 16.11.41 and now when building my Visual Studio solution I get:

qtmaind.lib(qtmain_win.obj) : error LNK2019: unresolved external symbol _main referenced in function _WinMain@16

The offending project is for the main application, which is a managed C++ CWinApp-based application. As described in the Microsoft documentation (https://learn.microsoft.com/en-us/cpp/mfc/cwinapp-the-application-class?view=msvc-170) –

Like any program for the Windows operating system, your framework application has a WinMain function. In a framework application, however, you do not write WinMain. It is supplied by the class library and is called when the application starts up.

I saw another old post that referenced this issue, Windows unicode commandline argv, but the discussion there seemed to be revolving around the correct form of main to use for a Unicode application. Unfortunately, my understanding of CWinApp applications leads me to believe I do not have access to main.

Any ideas? My assumption here is that this is a Microsoft problem related to the new version of Visual Studio, and I’m interested to know if anyone has encountered anything similar.

Edit: See my answer. Leaving this post up for a bit in case other people run into this issue and need to downgrade Qt Visual Studio Tools.

Leave a Reply

Your email address will not be published. Required fields are marked *