Can't build unreal 4.26 from source. Error C4668 and MSB3073

This is the output log:

Build started...
1>------ Build started: Project: UE4, Configuration: Development_Editor x64 ------
1>Using 'git status' to determine working set for adaptive non-unity build (O:\UE4.26_S).
1>Waiting for 'git status' command to complete
1>Building UE4Editor and ShaderCompileWorker...
1>Using Visual Studio 2019 14.29.30133 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133) and Windows 10.0.16299.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Building 4 actions with 8 processes...
1>  [1/4] Module.ElectraPlayerRuntime.1_of_4.cpp
1>O:\UE4.26_S\Engine\Source\ThirdParty\Windows\DirectX\include\d3d12.h(427): error C4668: 'WINAPI_PARTITION_GAMES' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(45,5): error MSB3073: The command "..\..\Build\BatchFiles\Build.bat -Target="UE4Editor Win64 Development" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "UE4.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========

First error C4668

Severity    Code    Description    Project    File    Line    Suppression State
Error    C4668    'WINAPI_PARTITION_GAMES' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'    UE4    O:\UnrealEngine\Engine\Source\ThirdParty\Windows\DirectX\include\d3d12.h    427 

Second error MSB3073

Severity    Code    Description    Project    File    Line    Suppression State
Error    MSB3073    The command "..\..\Build\BatchFiles\Build.bat -Target="UE4Editor Win64 Development" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 6.    UE4    C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets    45    

I’m currently rebuilding the engine after deleting the “Engine\Intermediate\Build\Win64\UE4Editor” - meant to fix the second error but I have already tried downloading the source to a separate folder and building the engine, didn’t work.

These types of errors are always a pain to try to figure out, so I can only really recommend some steps to hopefully resolve the issues:

  1. Make sure you have the latest versions of Visual Studio 2019 and the different workloads/components required for Unreal Engine 4. This includes .NET desktop development (.NET framework stuff), Desktop development with C++, etc.
  2. After installing the necessary components/updates, do a restart of the machine just to be sure.
  3. After a restart, perform the setup.bat, then generateprojectfiles.bat.
  4. If all goes well, open the UE4.sln in Visual Studio. Make sure the Startup project is UE4, the solution platform is Win64 and the solution configuration is Development Editor.
  5. Once this is all confirmed, right-click the UE4 project under the Solution Explorer and select Rebuild.

I hope this helps, and good luck :slight_smile:

347906-rebuild.png

For the NOOBS: I had these same errors and it was driving me nuts. For all the noobs like me out there, what solved it was ignoring the ErrorList window and looking at the Output window. There were errors (mostly to do with linking files) that were blocking the compilation but not appearing as proper “Errors” in the error list. I hope this is helpful for anyone else having issues.

1 Like