Inheriting from BrushComponent causes unsolvable linker error

I am trying to inherit from BrushComponent to add an event triggered when the mobility is changed to create a custom navigation modifier volume for a custom navigation plugin.

The problem is that as soon as you inherit from BrushComponent, the project no longer compiles due to these linker errors:

[2022.01.27-11.24.17:374][568]CompilerResultsLog: Error:   MyBrushComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UBrushComponent::PostLoad(void)" (?PostLoad@UBrushComponent@@UEAAXXZ)
[2022.01.27-11.24.17:374][568]CompilerResultsLog: Error:   Module.TileNav.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UBrushComponent::PostLoad(void)" (?PostLoad@UBrushComponent@@UEAAXXZ)
[2022.01.27-11.24.17:374][568]CompilerResultsLog: Error:   MyBrushComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FBoxSphereBounds __cdecl UBrushComponent::CalcBounds(struct FTransform const &)const " (?CalcBounds@UBrushComponent@@UEBA?AUFBoxSphereBounds@@AEBUFTransform@@@Z)
[2022.01.27-11.24.17:374][568]CompilerResultsLog: Error:   Module.TileNav.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FBoxSphereBounds __cdecl UBrushComponent::CalcBounds(struct FTransform const &)const " (?CalcBounds@UBrushComponent@@UEBA?AUFBoxSphereBounds@@AEBUFTransform@@@Z)
[2022.01.27-11.24.17:374][568]CompilerResultsLog: Error:   MyBrushComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FPrimitiveSceneProxy * __cdecl UBrushComponent::CreateSceneProxy(void)" (?CreateSceneProxy@UBrushComponent@@UEAAPEAVFPrimitiveSceneProxy@@XZ)
[2022.01.27-11.24.17:374][568]CompilerResultsLog: Error:   Module.TileNav.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FPrimitiveSceneProxy * __cdecl UBrushComponent::CreateSceneProxy(void)" (?CreateSceneProxy@UBrushComponent@@UEAAPEAVFPrimitiveSceneProxy@@XZ)
[2022.01.27-11.24.17:374][568]CompilerResultsLog: Error:   MyBrushComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UBrushComponent::GetUsedMaterials(class TArray<class UMaterialInterface *,class TSizedDefaultAllocator<32> > &,bool)const " (?GetUsedMaterials@UBrushComponent@@UEBAXAEAV?$TArray@PEAVUMaterialInterface@@V?$TSizedDefaultAllocator@$0CA@@@@@_N@Z)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   Module.TileNav.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UBrushComponent::GetUsedMaterials(class TArray<class UMaterialInterface *,class TSizedDefaultAllocator<32> > &,bool)const " (?GetUsedMaterials@UBrushComponent@@UEBAXAEAV?$TArray@PEAVUMaterialInterface@@V?$TSizedDefaultAllocator@$0CA@@@@@_N@Z)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   MyBrushComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual unsigned char __cdecl UBrushComponent::GetStaticDepthPriorityGroup(void)const " (?GetStaticDepthPriorityGroup@UBrushComponent@@UEBAEXZ)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   Module.TileNav.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual unsigned char __cdecl UBrushComponent::GetStaticDepthPriorityGroup(void)const " (?GetStaticDepthPriorityGroup@UBrushComponent@@UEBAEXZ)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   MyBrushComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UBrushComponent::IsEditorOnly(void)const " (?IsEditorOnly@UBrushComponent@@UEBA_NXZ)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   Module.TileNav.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UBrushComponent::IsEditorOnly(void)const " (?IsEditorOnly@UBrushComponent@@UEBA_NXZ)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   MyBrushComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UBrushComponent::ComponentIsTouchingSelectionBox(struct FBox const &,struct FEngineShowFlags const &,bool,bool)const " (?ComponentIsTouchingSelectionBox@UBrushComponent@@UEBA_NAEBUFBox@@AEBUFEngineShowFlags@@_N2@Z)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   Module.TileNav.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UBrushComponent::ComponentIsTouchingSelectionBox(struct FBox const &,struct FEngineShowFlags const &,bool,bool)const " (?ComponentIsTouchingSelectionBox@UBrushComponent@@UEBA_NAEBUFBox@@AEBUFEngineShowFlags@@_N2@Z)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   MyBrushComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UBrushComponent::ComponentIsTouchingSelectionFrustum(struct FConvexVolume const &,struct FEngineShowFlags const &,bool,bool)const " (?ComponentIsTouchingSelectionFrustum@UBrushComponent@@UEBA_NAEBUFConvexVolume@@AEBUFEngineShowFlags@@_N2@Z)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   Module.TileNav.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UBrushComponent::ComponentIsTouchingSelectionFrustum(struct FConvexVolume const &,struct FEngineShowFlags const &,bool,bool)const " (?ComponentIsTouchingSelectionFrustum@UBrushComponent@@UEBA_NAEBUFConvexVolume@@AEBUFEngineShowFlags@@_N2@Z)
[2022.01.27-11.24.17:375][568]CompilerResultsLog: Error:   G:\Fray\Plugins\TileNav\Binaries\Win64\UE4Editor-TileNav-1750.dll : fatal error LNK1120: 8 unresolved externals

The BrushComponent is part of the Engine module, and it is included in the plugin build.cs, but that does not fix the error. Moreover, I have added every single windows public, private and dynamic module in engine.build.cs to my plugin in an attempt to find the issue to no avail.

I have also inherited from BrushComponent in a clean project, without plugins, and had the same error. I have tested it in 4.26 and it also happens.

Is the brush component not supposed to be able to be inherited from? It is not a final class, so it should work? I do not know what else to try, any feedback is appreciated.

1 Like

Are you missing a generated header include somewhere?

1 Like

Hi Natalo, this is my header:


#pragma once

#include "CoreMinimal.h"
#include "Components/BrushComponent.h"
#include "MyBrushComponent.generated.h"

/**
 * 
 */
UCLASS()
class SEVENMASTERS_API UMyBrushComponent : public UBrushComponent
{
	GENERATED_BODY()
	
};

Had the same issue, and realized that for the inheritance to work, the UBrushComponent should be exposed with ENGINE_API.

Is there there a particular reason for not exposing the UBrushComponent as ENGINE_API?