Cannot declare FSlateBrush variable in custom C++ class

I’m trying to create a variable for my blueprint items for my inventory system, so that each blueprint can store a slate brush image as a default class variable to display in the inventory but my module isn’t compiling when I declare a variable of FSlateBrush type.

#include "SlateBrush.h"

UPROPERTY(editAnywhere, BlueprintReadWrite, Category = "Appearance")
    FSlateBrush brush;

The compiler outputs this error

error LNK2019: unresolved external symbol “__declspec(dllimport) public: __cdecl FSlateBrush::FSlateBrush(void)” (_imp??0FSlateBrush@@QEAA@XZ) referenced in function …

You need to go to your Build.cs file, which is stored in Source folder, and uncomment or add this line:

PrivateDependencyModuleNames.AddRange(new string[] { “Slate”, “SlateCore” });

2 Likes