Unresolved external with USelection::SelectObjectEvent.AddUObject

I upgraded an old project from 4.26 to 5.3 and am getting this build error now:

BallBounceBaseActor.cpp.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: static class USelection::FOnSelectionChanged USelection::SelectObjectEvent” (_imp?SelectObjectEvent@USelection@@2VFOnSelectionChanged@1@A) referenced in function “public: __cdecl ABallBounceBaseActor::ABallBounceBaseActor(void)” (??0ABallBounceBaseActor@@QEAA@XZ)

In the header I have:

private:
#if WITH_EDITOR 
	void OnObjectSelected(UObject* Object);
#endif

Constructor:

#if WITH_EDITOR 
	USelection::SelectObjectEvent.AddUObject(this, &ABallBounceBaseActor::OnObjectSelected);
#endif

Function:

#if WITH_EDITOR 
void ABallBounceBaseActor::OnObjectSelected(UObject* Object)
{
	FEditorScriptExecutionGuard ScriptGuard;
	{
		if (Object == this)
		{
            // Logic
		}
		else if (!IsSelected())
		{
            // Logic
		}
	}
}

Still having this issue, have no idea how to fix.

I have the same problem, have you found the solution by any chance?

For anyone still looking for this. You need to add PrivateDepencencyModuleNames in your project’s .Build.cs.

if (Target.bBuildEditor)
{
    PrivateDependencyModuleNames.AddRange(
        new string[] {
                "LevelEditor",
                "UnrealEd",
        });
}
1 Like