How can I resolve the error "Error LNK2019: unresolved external symbol" related to FSlateDynamicImageBrush?

I’m not sure why this is happening been following some code examples and found that when I try and create an FSlateDynamicImageBrush I get the following error:

error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FSlateDynamicImageBrush::FSlateDynamicImageBrush(class UTexture2D *,struct FVector2D const &,class FName,struct FLinearColor const &,enum ESlateBrushTileType::Type,enum ESlateBrushImageType::Type)" (__imp_??0FSlateDynamicImageBrush@@QEAA@PEAVUTexture2D@@AEBUFVector2D@@VFName@@AEBUFLinearColor@@W4Type@ESlateBrushTileType@@W45ESlateBrushImageType@@@Z) referenced in function "public: void __cdecl SetImage(class UTexture2D *)" (?SetImage@@QEAAXPEAVUTexture2D@@@Z)

Here is the relevant code that generates this linker error:

TSharedPtr<FSlateDynamicImageBrush> ButtonImage;
void SetImage(UTexture2D* Texture)
{
	if (Texture != NULL)
	{
		ButtonImage.Reset();
		ButtonImage = TSharedPtr<FSlateDynamicImageBrush>(new FSlateDynamicImageBrush(
			Texture,
			FVector2D(Texture->GetSizeX(), Texture->GetSizeY()),
			Texture->GetFName()));
	}
}

When I look at the prototype for the FSlateDynamicImageBrush the only difference I can see is that in the error it is handling the Texture->GetFName() request as passing a class instead of a const FName object to the constructor. When I rem out lines 7-10 it compiles without complaint but as soon as I put these lines back in the linker fails.

#SlateCore

Have you tried adding SlateCore to your build.cs , in additon to Slate?

 //Private Module Dependencies  
PrivateDependencyModuleNames.AddRange(new string[] { "InputCore", "Slate", "SlateCore" });

:slight_smile:

Rama

Thanks that did it. I search everywhere for an answer but nothing really discussed adding those modules to the build. I’ll probably find this on my own but just wondering is there somewhere that talks about which models are available and why we would use them?