VS2017从15.5.4更新至15.6.1后出现invoke_main未解析外部符号错误
Hey there, let's work through this issue you're hitting. Since your code runs perfectly on VS2017 15.5.4 but throws that invoke_main unresolved external error after updating to 15.6.1, the problem is almost certainly tied to project configuration changes introduced in the newer Visual Studio version. Here are the most common fixes to try:
1. Verify Subsystem and Entry Point Settings
This is the most frequent cause for this error after a VS update:
- Right-click your project → Properties → Linker → System
- Make sure the Subsystem matches your project type: choose
Console (/SUBSYSTEM:CONSOLE)for console apps, orWindows (/SUBSYSTEM:WINDOWS)for GUI apps. Mismatched subsystems can prevent the compiler from recognizingmainorWinMain.
- Make sure the Subsystem matches your project type: choose
- Next, go to Linker → Advanced → Entry Point
- This field should be empty (letting the compiler auto-detect the entry point). If there's a custom value here, clear it and rebuild.
2. Check Precompiled Header Configuration
VS updates sometimes mess with precompiled head settings:
- Right-click project → Properties → C/C++ → Precompiled Headers
- Ensure the Precompiled Header option matches your original setup (either
Use (/Yu)orNot Using Precompiled Headers). If it looks off, toggle the setting and toggle it back, or delete your.pchfile and do a full rebuild.
- Ensure the Precompiled Header option matches your original setup (either
3. Confirm Project Type Isn't Changed
Occasionally, VS updates can accidentally alter your project type:
- Right-click project → Properties → General
- Check the Project Type field to make sure it's still the same as it was in 15.5.4 (e.g., Console Application, Windows Application). If it changed, switch it back.
4. Align Platform Toolset Version
Newer VS versions might default to an updated toolset, which can clash with existing dependencies:
- Right-click project → Properties → General → Platform Toolset
- Select
v141(the toolset for VS2017) if it's not already selected. If you have external libraries, make sure they're built with the same toolset version, or rebuild them with 15.6.1's toolset.
- Select
5. Double-Check main Function Declaration
While your code works on the older version, it's worth confirming your main function follows standard C++ syntax:
- Ensure it's declared as either:
orint main()
Avoid non-standard modifiers likeint main(int argc, char* argv[])static—newer compiler versions might enforce stricter compliance here.
Try these steps one by one, starting with the subsystem/entry point checks—those usually resolve this specific error. Since your code works on 15.5.4, this is definitely a configuration mismatch rather than a problem with your code itself.
内容的提问来源于stack exchange,提问作者Velchivz

