I have an MFC C++ project, which builds and runs just fine with Visual Studio 2022 on Windows 10. The project doesn't use Qt at all. After I installed Qt 6.2.1 with vcpkg, project stopped building with this linker error:
1>Qt6EntryPoint.lib(qtentrypoint_win.cpp.obj) : error LNK2019: unresolved external symbol main referenced in function WinMain
Again, there is no usage of Qt6 in my project. Going to project's Configuration Properties
and disabling Use Vcpkg
makes it build again. What is going on here and how to fix it without disabling vcpkg?
I created a new C++ MFC App with VS project wizard and default settings. It builds fine with vcpkg enabled.
The only reasonable explanation I can offer is that many generations ago, older VS, older Windows, my project was using a few classes from Qt4 core for a while, which caused problems, so that functionality was removed. I continued to develop it on Windows without Qt installed. Is it possible that some reference to Qt is still lurking around? How to find it? I checked settings several times and couldn't find any.
I looked at the order of library search (/VERBOSE:Lib
) and with vcpkg -> Use Autolink
enabled, vcpkg folders are searched first. Is there a way to make the linker search system folders first?
Here is what's happening:
1> Searching C:\src\vcpkg\installed\\x64-windows\lib\Qt6EntryPoint.lib:
1> Found WinMain
1> Referenced in msvcrt.lib(exe_winmain.obj)
1> Loaded Qt6EntryPoint.lib(qtentrypoint_win.cpp.obj)
Excluding Qt6EntryPoint.lib with /NODEFAULTLIB:"Qt6EntryPoint.lib"
has no effect. Is there another way to exclude it?