Can't solve a linker error developing a Custom Editor Mode

Hi!

I’m doing a custom Editor Mode for UE5 through a EditorModeTool module class (inherits from ITemplateModuleListener).

However I have a “unresolved external” linker error since some time ago that I can’t still figure out how to solve. I’ll leave the error below but so far I know it happens in the OnModuleStartup() function of the module where I register the Editor Mode using the following code:

FEditorModeRegistry::Get().RegisterMode<FEditorMode>(
	FCustomEditorMode::ModeID,
	FText::FromString("CustomMode"),
	FSlateIcon(customStyleSet->GetStyleSetName(), FName("icon"), FName("icon.Small")),
	true,
	500);

And judging by the error wording I assume the problem is that the RegisterMode() function is trying to create a FEditorModeInfo(...) that triggers the mentioned linker error. If I try to create the FEditorModeInfo by myself (for instance in the OnModuleStartup()) I get the linker error referencing on my function.

So the thing is that I don’t know exactly what is causing this, I tried to include a couple of files in my class and remove some (looking at the includes that the related files have) but nothing is working, and since I’ve been with this for some days I’m quite stuck :frowning:, does someone sees what is going on?

The linker error says the following:

error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FEditorModeInfo::FEditorModeInfo(class FName,class FText,struct FSlateIcon,class TAttribute<bool>,int)" (__imp_??0FEditorModeInfo@@QEAA@VFName@@VFText@@UFSlateIcon@@V?$TAttribute@_N@@H@Z) referenced in function "public: virtual void __cdecl EditorModeTool::OnModuleStartup(void)" (?OnModuleStartup@EditorModeTool@@UEAAXXZ)
1 Like

Try adding “UnrealEd” to your dependency modules in your Build.cs file

It already was, I tried removing it but it didn’t worked :frowning:

I’m looking that the FEditorModeInfo has EDITORFRAMEWORK_API in its constructors, which I think is basically a declspec(import), maybe that has something to do?

Oh well that looks like a new UE5 exoticism.
Well try adding “EditorFramework” to the dependencies then

2 Likes

Wow that made it working!!! Thank you very much, I was super stuck and frustrated with this :slight_smile:

Awesome! Thanks!

I got here via google and I want to say to anyone coming after me, don’t forget to add YOUR_MODULE_NAME_API to your C++ class