[Linker Error] FWidgetRenderer

Hey fellas! I’m trying to make a custom actor that would render a widget component in a render target texture. To do this I need FWidgetRenderer.

After trying to create it I get a linker error.

Line:

TSharedPtr<FWidgetRenderer> WidgetRenderer = MakeShareable(new FWidgetRenderer(true));

Error:
error LNK2019: unresolved external symbol “__declspec(dllimport) public: __cdecl FWidgetRenderer::FWidgetRenderer(bool,bool)” (_imp??0FWidgetRenderer@@QEAA@_N0@Z) referenced in function “protected: virtual void __cdecl APlayerPawnBase::BeginPlay(void)” (?BeginPlay@APlayerPawnBase@@MEAAXXZ)

I’ve added dependancies to the build.cs (tried both public and private but both produce the same error):

public class VRRPG_CPP : ModuleRules
{
	public VRRPG_CPP(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
	
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Slate", "SlateCore" });

		PrivateDependencyModuleNames.AddRange(new string[] {  });

		// Uncomment if you are using Slate UI
		PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
		
		// Uncomment if you are using online features
		// PrivateDependencyModuleNames.Add("OnlineSubsystem");

		// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
	}
}

Before anyone asks, yeah, I did generate solution project files after changing build.cs but the error remains…

FWidgetRenderer is in UMG module so you need to add that in depency

For future if you want ot check which module you need to add to depency if you got linker errors go to API refrence of the element that causeing it and look on the bottom of the page, you will see both module name where that thing is declered as well as header file:

If you can’t find it in API refrence you need to search is source code, the module name is directory name of 2nd directory after Source directoruy, so in case of FWidgetRenderer directory after Runtime:

UnrealEngine/Engine/Source/Runtime/UMG/Private/Slate/WidgetRenderer.cpp

That the case for modules in engine for plugins and game projects modules are right away after Source directory

Thanks!
This did solve the issue with FWidgetRenderer, however I’m left with this one:

Creating library D:\Unreal Projects\VRRPG_CPP\Intermediate\Build\Win64\UE4Editor\Development\VRRPG_CPP\UE4Editor-VRRPG_CPP.suppressed.lib and object D:\Unreal Projects\VRRPG_CPP\Intermediate\Build\Win64\UE4Editor\Development\VRRPG_CPP\UE4Editor-VRRPG_CPP.suppressed.exp
2>PlayerPawnBase.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl FDeferredCleanupInterface::FinishCleanup(void)” (?FinishCleanup@FDeferredCleanupInterface@@UEAAXXZ)

Do you know anything about that? I’m not sure what it’s referring to.

edit: PS. thanks for the pro tip :slight_smile:

Did you read what i wrote? Look on API reference :stuck_out_tongue:

Silly me :slight_smile: Works like a charm! Bless you!