UE5在VisualStudio升级后产生C++无法编译的问题

往期的虚幻引擎项目在VS更新后,编译时会报错,这一般出现在VS升级之后,UE对于VC++的编译器定位没有更新导致;

有出现如下问题:

问题1:

Running I:/EPCI/Epic Games/UE_5.3/Engine/Build/BatchFiles/Build.bat -projectfiles -project=“I:/GAME/PJ/我的项目2/我的项目2.uproject” -game -rocket -progress
Using bundled DotNet SDK version: 6.0.302
Running UnrealBuildTool: dotnet “…..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -projectfiles -project=“I:/GAME/PJ/???2/???2.uproject” -game -rocket -progress
Log file: C:\Users\Fox\AppData\Local\UnrealBuildTool\Log_GPF.txt

Some Platforms were skipped due to invalid SDK setup: IOS, Android, Linux, LinuxArm64.
See the log file for detailed information

Generating VisualStudio project files:
Discovering modules, targets and source code for project…
Microsoft platform targets must be compiled with Visual Studio 2022 17.4 (MSVC 14.34.x) or later for the installed engine. Please update Visual Studio 2022 and ensure no configuration is forcing WindowsTargetRules.Compiler to VisualStudio2019. The current compiler version was detected as: 14.29.30152

问题1解决方案:

打开VS安装器,修改,内部模组,把旧有的MSVC全部取消;

MSVC v142 - VS2019 C++ x64/x86 package
MSVC v141 - VS2017 C++ x64/x86 package
MSVC v140 - VS2015 C++ x64/x86 package
After uncheck the options, create UE5.3 C++ project again.

20231222-103022

问题2:

编译后报错

LNK1104 cannot open file 'legacy_stdio_definitions.lib'

问题2解决方案:

这个文件其实依然是由于UE定位在旧MSVC的目录导致的无法寻找到,此时将UE Editor关闭,然后直接VS打开虚幻工程,并重生成工程即可;

再次打开UE5,其编译也就正常了;