Error LNK2019: unresolved external symbol

I copied a code from this link and transfered it to ue5 and i’ve come across this error:

BPFL_Game_Settings_Helpers.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class FDynamicRHI * GDynamicRHI" (__imp_?GDynamicRHI@@3PEAVFDynamicRHI@@EA) referenced in function "public: static class TArray<struct FScreenResolutionRHIBP,class TSizedDefaultAllocator<32> > __cdecl UBPFL_Game_Settings_Helpers::GetDisplayAdapterScreenResolutions(void)" (?GetDisplayAdapterScreenResolutions@UBPFL_Game_Settings_Helpers@@SA?AV?$TArray@UFScreenResolutionRHIBP@@V?$TSizedDefaultAllocator@$0CA@@@@@XZ)

BPFL_Game_Settings_Helpers.h

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "BPFL_Game_Settings_Helpers.generated.h"

USTRUCT(BlueprintType)
struct FScreenResolutionRHIBP
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ScreenResolution)
		int32 Width;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ScreenResolution)
		int32 Height;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ScreenResolution)
		int32 RefreshRate;

	FScreenResolutionRHIBP()
	{
		Width = Height = RefreshRate = 0;
	}
};

UCLASS()
class CHESS_API UBPFL_Game_Settings_Helpers : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
		
public:

	UFUNCTION(BlueprintPure, Category = Utility)
		static TArray<struct FScreenResolutionRHIBP> GetDisplayAdapterScreenResolutions();
};

BPFL_Game_Settings_Helpers.cpp

#include "BPFL_Game_Settings_Helpers.h"
#include "RHI.h"

TArray<FScreenResolutionRHIBP> UBPFL_Game_Settings_Helpers::GetDisplayAdapterScreenResolutions()
{
	TArray<FScreenResolutionRHIBP> ResolutionsToReturn;
	FScreenResolutionArray Resolutions;
	if (RHIGetAvailableResolutions(Resolutions, false))
	{
		// Preallocate memory to store all elements
		ResolutionsToReturn.Reserve(Resolutions.Num());

		for (const FScreenResolutionRHI& EachResolution : Resolutions)
		{
			FScreenResolutionRHIBP resolution;
			resolution.Width = EachResolution.Width;
			resolution.Height = EachResolution.Height;
			resolution.RefreshRate = EachResolution.RefreshRate;

			ResolutionsToReturn.Add(resolution);
		}
	}

	return ResolutionsToReturn;
}

Go to your PROJECTNAME.Build.cs file, open it and add “RHI” in your PublicDependencyModuleNames list.

When you get that message you should google the class name your error is pointing to and check which module dependecy you need to add to your project.

5 Likes

Thanks a lot

1 Like

I seem to be having a similar issue, but I can’t figure out what the missing module would be. Would you mind taking a look over there → Can not link plugin