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;
}