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
Source Path
Local Engine 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

c#
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Epic Games, Inc. All Rights Reserved.

using System.IO;
using UnrealBuildTool;

public class DirectX : ModuleRules
{
	public static string GetDir(ReadOnlyTargetRules Target)
	{
		return Target.UEThirdPartySourceDirectory + "Windows/DirectX";
	}

	public static string GetIncludeDir(ReadOnlyTargetRules Target)
	{
		return GetDir(Target) + "/include";
	}

	public static string GetLibDir(ReadOnlyTargetRules Target)
	{
		return Path.Combine(GetDir(Target), "Lib", Target.Architecture.WindowsName) + "/";
	}

	public static string GetDllDir(ReadOnlyTargetRules Target)
	{
		return Path.Combine(Target.RelativeEnginePath, "Binaries/ThirdParty/Windows/DirectX", Target.Architecture.WindowsName) + "/";
	}

	public DirectX(ReadOnlyTargetRules Target) : base(Target)
	{
		Type = ModuleType.External;
	}
}

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
Refresh project

Conclusion

Maybe this is a bug in the version

Engine Version:5.2