4.22.3 building from source raises C2338: Windows headers require the default packing option

I built 4.22.3 from source with command

RunUAT.bat BuildGraph -target="Make Installed Build Win64" -script=Engine/Build/InstalledEngineBuild.xml -set:WithDDC=false -set:HostPlatformOnly=true

with Visual Studio 2019(16.2.3, MSVC v14.22) and Windows 10 SDK(10.0.18362.0).

And when Compile UE4Game Win32, compiler raises this error:

C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winnt.h(2482): error C2338: Windows headers require the default packing option. Changing this can lead to memory corruption. This diagnostic can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined.

Can I surpress this error or should I modify source code(or is there any ideas to fix this)?

I found that vctoolchain of UBT forces /Zp8 on 64bit, /Zp4 on 32bit. But there’s no information about unreal should use specific memory packing. I just surressed that diagnostic error.

I have the same issue as well.

Here is the solution i found:

So, the problem is that the new Windows 10 SDK version (10.0.18362.0) has new restrictions that cause the build to fail.

I was able to successfully build it using the 10.0.16299.0 SDK. Therefore, I would recommend you to switch an earlier SDK until the issue is resolved.

You would need to change WindowsSdkVersion in Engine/Source/Programs/UnrealBuildTool/Platforms/Windows/UEBuildWindows.cs to make sure the Automation Tool uses the correct Windows SDK version.

I hope this finds you well.

Greetings,
xCocoDev

I have “10.0.16299.0” installed and tried these settings in UEBuildWindows.cs:


public string WindowsSdkVersion = "10.0.16299.0";

static readonly VersionNumber[] PreferredWindowsSdkVersions = new VersionNumber[]
		{
			VersionNumber.Parse("10.0.16299.0")
		};

I have deleted all Intermediate files.
Unfortunately UE 4.25 still uses “10.0.18362.0” in the generated .vcxproj and in the packaging build.

Are there other files where I can set the Windows SDK?

Greets

Yes. in BuildConfiguration.xml.

Have searched these folders for BuildConfiguration.xml:

  • Engine/Saved/UnrealBuildTool/BuildConfiguration.xml
  • User Folder/AppData/Roaming/Unreal Engine/UnrealBuildTool/BuildConfiguration.xml
  • My Documents/Unreal Engine/UnrealBuildTool/BuildConfiguration.xml*

Nowhere is the Windows SDK set.

Ok, its solved!
I have edit the User Folder/AppData/Roaming/Unreal Engine/UnrealBuildTool/BuildConfiguration.xml to:

<BuildConfiguration>	
</BuildConfiguration>
<WindowsPlatform>
	<WindowsSdkVersion>10.0.16299.0</WindowsSdkVersion>
</WindowsPlatform>

This changes the WindowsSdk for all user projects.
However, doing this for the project only by adding the file under my_project/config/UnrealBuildTool/BuildConfiguration.xml did not work.

Thanks very much for help. Greets

This is, at least for me, the working solution provided by the Unreal Support. Just add this to your main .Build.cs file:

PublicDefinitions.Add("WINDOWS_IGNORE_PACKING_MISMATCH");

Nothing else to add or modify.

Greets, solarisx

Hello, Can you give me The main .Build.cs FilePath, I Can’t find the file , Thanks!

‘your project folder\Source\project name\project name.Build.cs’
To get a .Build.cs file and a Source folder you have to make you project a c++ project or at leaste add a c++ dummy class file to your project from the unreal editor. https://docs.unrealengine.com/en-US/ProgrammingAndScripting/ProgrammingWithCPP/CPPProgrammingQuickStart/index.html

I meet this error when build engine from source code ,Use require WindosSDK could work, Thank you!