c++visual-studioqtqt-vs-addin

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.


Solution

  • Mystery solved - turns out it was a Qt VS Tools update (from 3.2.0.47 to 3.3.0.13) that did it. Rolling back to an earlier version seems to fix the problem.