Link error using render commands from C++

This could be related to another (link based) problem I am having:

Link error using GetVectorParameterByName in C++

But I thought I’d raise a separate question since it might not be related.

I am attempting to render a material to a RenderTarget. However, at the moment I am just trying to clear the render target and I am getting link errors.

FTextureRenderTargetResource* TextureTargetResource = DisplacementTarget->GameThread_GetRenderTargetResource();
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(UpdateSpectrumCSCommand,
	FTextureRenderTargetResource*, TextureRenderTarget, TextureTargetResource,
	UMaterial*, RenderingMaterial, MaterialToRender,
{
	RHISetRenderTarget(TextureRenderTarget->GetRenderTargetTexture(), NULL);
	//RHIClear(true, FLinearColor::Transparent, false, 0.f, false, 0, FIntRect());
});

This generates the following link errros (compressed, full set at the bottom):

unresolved external symbol: void RHISetRenderTargets(unsigned int, FRHIRenderTargetView const *,FRHITexture *,unsigned int,FRHIUnorderedAccessView * const *)
referenced in: void RHISetRenderTarget(FRHITexture *,FRHITexture *)

This is strange as the method it could not find is defined in the same header file as the method it is referenced in, so I do not see how it is failing to find this method.

Below is the full link error output:

MaterialToTextureRenderer.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl RHISetRenderTargets(unsigned int,class FRHIRenderTargetView const *,class FRHITexture *,unsigned int,class FRHIUnorderedAccessView * const *)" (__imp_?RHISetRenderTargets@@YAXIPEBVFRHIRenderTargetView@@PEAVFRHITexture@@IPEBQEAVFRHIUnorderedAccessView@@@Z) referenced in function "void __cdecl RHISetRenderTarget(class FRHITexture *,class FRHITexture *)" (?RHISetRenderTarget@@YAXPEAVFRHITexture@@0@Z)
MaterialToTextureRenderer.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static enum ENamedThreads::Type __cdecl FRenderCommand::GetDesiredThread(void)" (__imp_?GetDesiredThread@FRenderCommand@@SA?AW4Type@ENamedThreads@@XZ) referenced in function "private: class TRefCountPtr<class FGraphEvent> __cdecl TGraphTask<class `public: virtual void __cdecl AMaterialToTextureRenderer::Tick(float)'::`2'::EURCMacro_UpdateSpectrumCSCommand>::Setup(class TArray<class TRefCountPtr<class FGraphEvent>,class TInlineAllocator<4,class FDefaultAllocator> > const *,enum ENamedThreads::Type)" (?Setup@?$TGraphTask@VEURCMacro_UpdateSpectrumCSCommand@?1??Tick@AMaterialToTextureRenderer@@UEAAXM@Z@@@AEAA?AV?$TRefCountPtr@VFGraphEvent@@@@PEBV?$TArray@V?$TRefCountPtr@VFGraphEvent@@@@anonymous_user_e71e0d8a?$TInlineAllocator@$03VFDefaultAllocator@@@@@@W4Type@ENamedThreads@@@Z)
MaterialToTextureRenderer.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static enum ESubsequentsMode::Type __cdecl FRenderCommand::GetSubsequentsMode(void)" (__imp_?GetSubsequentsMode@FRenderCommand@@SA?AW4Type@ESubsequentsMode@@XZ) referenced in function "public: static class TGraphTask<class `public: virtual void __cdecl AMaterialToTextureRenderer::Tick(float)'::`2'::EURCMacro_UpdateSpectrumCSCommand>::FConstructor __cdecl TGraphTask<class `public: virtual void __cdecl AMaterialToTextureRenderer::Tick(float)'::`2'::EURCMacro_UpdateSpectrumCSCommand>::CreateTask(class TArray<class TRefCountPtr<class FGraphEvent>,class TInlineAllocator<4,class FDefaultAllocator> > const *,enum ENamedThreads::Type)" (?CreateTask@?$TGraphTask@VEURCMacro_UpdateSpectrumCSCommand@?1??Tick@AMaterialToTextureRenderer@@UEAAXM@Z@@@SA?AVFConstructor@1@PEBV?$TArray@V?$TRefCountPtr@VFGraphEvent@@@@anonymous_user_e71e0d8a?$TInlineAllocator@$03VFDefaultAllocator@@@@@@W4Type@ENamedThreads@@@Z)
MaterialToTextureRenderer.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) bool GIsThreadedRendering" (__imp_?GIsThreadedRendering@@3_NA)
MaterialToTextureRenderer.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) bool GMainThreadBlockedOnRenderThread" (__imp_?GMainThreadBlockedOnRenderThread@@3_NA)

#RHI

If you navigate to your game / source / build.cs

Did you add RHI as a public dependency?

PublicDependencyModuleNames.AddRange(new string[] { 
                "Core", 
                "CoreUObject", 
                "Engine", 
                "InputCore",
                
                "RHI", 
                "RenderCore", 
                "ShaderCore"
        });

Yep, that now compiles, was looking in the other .cs file. Thanks!