UE5.2 Solve the error about DirectX

Preface

After downloading Unreal 5.2 through Launcher, when creating a C++project and opening the project through Rider, the engine project will display an inexplicable red warning. After troubleshooting the project content, it was found that the errors were all caused by the lack of DirectX. Most of the errors are in the Build. cs file. The warning section states that DirectX does not exist, but compiling the project does not have any impact (non source code engineering).

The main purpose of the Build.cs file in the Unreal Engine is to inform UBT of the reference relationship between modules and libraries when building a project. Compilation can be done by stating that the library is not missing, while Rider reports an error indicating that the relationship cannot be found in the context. Compare the local engine code with the official Git source code, mainly checking the Source/ThirdParty/Windows directory. Found that the Build.cs file is missing in the DirectX directory compared to the engine source directory.

Source Path
Local Engine Path

Solve Method

1、Download the Build.cs file

Git source download,login your github account,download DirectX.Build.cs

You can also directly copy the code below and create your own Build.cs file

 1// Copyright Epic Games, Inc. All Rights Reserved.
 2
 3using System.IO;
 4using UnrealBuildTool;
 5
 6public class DirectX : ModuleRules
 7{
 8	public static string GetDir(ReadOnlyTargetRules Target)
 9	{
10		return Target.UEThirdPartySourceDirectory + "Windows/DirectX";
11	}
12
13	public static string GetIncludeDir(ReadOnlyTargetRules Target)
14	{
15		return GetDir(Target) + "/include";
16	}
17
18	public static string GetLibDir(ReadOnlyTargetRules Target)
19	{
20		return Path.Combine(GetDir(Target), "Lib", Target.Architecture.WindowsName) + "/";
21	}
22
23	public static string GetDllDir(ReadOnlyTargetRules Target)
24	{
25		return Path.Combine(Target.RelativeEnginePath, "Binaries/ThirdParty/Windows/DirectX", Target.Architecture.WindowsName) + "/";
26	}
27
28	public DirectX(ReadOnlyTargetRules Target) : base(Target)
29	{
30		Type = ModuleType.External;
31	}
32}

2、Copy file to the engine path

Copy download file to\Epic Games\UE_5.2\Engine\Source\ThirdParty\Windows\DirectX

3、Refresh solution

Close Rider, refresh the project file in the project, generate a new solution, and then open Rider to wait for the project to refresh. The problem can be resolved.

Refresh project

Conclusion

Maybe this is a bug in the version

Engine Version:5.2

Translations:

Comment