# Can you fix UStateTreeAIComponent to be inherited in c++?

**URL:** <https://forums.unrealengine.com/t/can-you-fix-ustatetreeaicomponent-to-be-inherited-in-c/1890611>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, CPP\
**Created:** [June 5, 2024, 10:18am UTC](https://forums.unrealengine.com/t/can-you-fix-ustatetreeaicomponent-to-be-inherited-in-c/1890611 "2024-06-05T10:18:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justrenis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Justrenis](https://forums.unrealengine.com/u/Justrenis)\
**Post date:** [June 5, 2024, 10:18am UTC](https://forums.unrealengine.com/t/can-you-fix-ustatetreeaicomponent-to-be-inherited-in-c/1890611/1 "2024-06-05T10:18:36Z")

</div>

UStateTreeComponent works perfectly fine, with all modules included, but not UStateTreeAIComponent, it will give this error:

0\>Module.PossessionGame.1.cpp.obj: Error : LNK2019: unresolved external symbol “private: static class UClass \* \_\_cdecl UStateTreeAIComponent::GetPrivateStaticClass(void)” (?GetPrivateStaticClass@UStateTreeAIComponent@@CAPEAVUClass@@XZ) referenced in function “public: static class UClass \* \_\_cdecl UStateTreeAIComponent::StaticClass(void)” (?StaticClass@UStateTreeAIComponent@@SAPEAVUClass@@XZ)  
0\>Module.PossessionGame.1.cpp.obj: Error : LNK2019: unresolved external symbol “public: \_\_cdecl UStateTreeAIComponent::UStateTreeAIComponent(class FObjectInitializer const &)” (??0UStateTreeAIComponent@@QEAA@AEBVFObjectInitializer@@@Z) referenced in function “public: \_\_cdecl UCustomStateTreeAIComponent::UCustomStateTreeAIComponent(class FObjectInitializer const &)” (??0UCustomStateTreeAIComponent@@QEAA@AEBVFObjectInitializer@@@Z)  
0\>Module.PossessionGame.1.cpp.obj: Error : LNK2019: unresolved external symbol “public: \_\_cdecl UStateTreeAIComponent::UStateTreeAIComponent(class FVTableHelper &)” (??0UStateTreeAIComponent@@QEAA@AEAVFVTableHelper@@@Z) referenced in function “public: \_\_cdecl UCustomStateTreeAIComponent::UCustomStateTreeAIComponent(class FVTableHelper &)” (??0UCustomStateTreeAIComponent@@QEAA@AEAVFVTableHelper@@@Z)  
0\>Module.PossessionGame.1.cpp.obj: Error : LNK2019: unresolved external symbol “public: virtual \_\_cdecl UStateTreeAIComponent::~UStateTreeAIComponent(void)” (??1UStateTreeAIComponent@@UEAA@XZ) referenced in function “public: virtual \_\_cdecl UCustomStateTreeAIComponent::~UCustomStateTreeAIComponent(void)” (??1UCustomStateTreeAIComponent@@UEAA@XZ)  
0\>Module.PossessionGame.1.cpp.obj: Error : LNK2001: unresolved external symbol "public: virtual class TSubclassOf \_\_cdecl UStateTreeAIComponent::GetSchema(void)const " (?GetSchema@UStateTreeAIComponent@@UEBA?AV?$TSubclassOf@VUStateTreeSchema@@@@XZ)  
0\>Module.PossessionGame.1.cpp.obj: Error : LNK2001: unresolved external symbol “public: virtual bool \_\_cdecl UStateTreeAIComponent::SetContextRequirements(struct FStateTreeExecutionContext &,bool)” (?SetContextRequirements@UStateTreeAIComponent@@UEAA\_NAEAUFStateTreeExecutionContext@@_N@Z)  
0\>UnrealEditor-PossessionGame.dll: Error : LNK1120: 6 unresolved externals

---

<div class="post-metadata">

**Author:** ![jmcginnis\_ose](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jmcginnis\_ose](https://forums.unrealengine.com/u/jmcginnis_ose)\
**Post date:** [February 3, 2025, 10:28pm UTC](https://forums.unrealengine.com/t/can-you-fix-ustatetreeaicomponent-to-be-inherited-in-c/1890611/2 "2025-02-03T22:28:11Z")

</div>

The issue is that the UStateTreeAIComponent isn’t API exposed. If you are building the engine, you need to add GAMEPLAYSTATETREEMODULE\_API to StateTreeAIComponent.h like so

```auto
class GAMEPLAYSTATETREEMODULE_API UStateTreeAIComponent : public UStateTreeComponent

```

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [February 8, 2025, 2:37pm UTC](https://forums.unrealengine.com/t/can-you-fix-ustatetreeaicomponent-to-be-inherited-in-c/1890611/3 "2025-02-08T14:37:01Z")

</div>

> [@Justrenis](#):
>
> GetPrivateStaticClass

You have a linker error

Make sure your build file includes the module

[GameplayStateTreeModule](https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Plugins/GameplayStateTreeModule)

it is also dependent on “AIModule” because internally it references [UBrainComponent](https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/AIModule/UBrainComponent)  
in your public dependencies

You also need to include the following header either in your header file or forward declare the component and put the include in your cpp file (a better option)

```auto
#include "Components/StateTreeAIComponent.h"

```

 ![build](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/4/0/c40d1f814cee9eec12912335656dbd3bd6381069.jpeg)

Successful compile below:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/2/e/b2ecc506a270c6061ea4eb8826639e9e41be4487.png)
