Slate linking error with SlateCore internal classes

I’m making Slate widgets and UMGs as a plugin (“NaItemSystem”) and got LNK2019 compiling errors which seem to be happening in UE4 SlateCore internal classes.
3 unresolved symbols overall.

Blockquote
1>Module.NaItemSystem.gen.cpp.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: __cdecl FKey::FKey(void)” (_imp??0FKey@@QEAA@XZ) referenced in function “public: __cdecl FPointerEvent::FPointerEvent(void)” (??0FPointerEvent@@QEAA@XZ)
1>Module.NaItemSystem.gen.cpp.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: __cdecl FKey::~FKey(void)” (_imp??1FKey@@QEAA@XZ) referenced in function “public: virtual __cdecl FPointerEvent::~FPointerEvent(void)” (??1FPointerEvent@@UEAA@XZ)
1>Module.NaItemSystem.gen.cpp.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: struct FKey & __cdecl FKey::operator=(struct FKey const &)” (_imp??4FKey@@QEAAAEAU0@AEBU0@@Z) referenced in function “public: void __cdecl FPointerEvent::operator=(struct FPointerEvent const &)” (??4FPointerEvent@@QEAAXAEBU0@@Z)

It seems that the error happens with FKey and FPointerEvent, which are both SlateCore internal classes/structs. SlateCore and Slate modules have already been added in the build.cs file.

I found most lnk2019 errors are due to (a) missing function implementation in .cpp file or (b) missing include files or (c) missing API declaration (e.g. NAITEMSYSTEM_API) or (d) missing modules in build.cs. However I’ve checked the all 4 aspects above and found nothing causing this issue.

o/
Afair to use others module type or function in question needs to have MACRO_API applied to it:
image

FKey is declared in module InputCore, you have to include it in your dependencies as well.

1 Like

Oh, it works! Thank you very much!