Using AIController giving me errors

Edit: I initially thought the error was due to using a Behavior tree but I actually got the error when I used the AIController. Not related to anything else.

I am getting a lot of erros when I include “BehaviorTree/BehaviorTreeComponent.h” in my controller .h file

Code

.h

#pragma once

#include "AIController.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "BehaviorTree/BehaviorTreeComponent.h"
#include "BehaviorTree/BehaviorTree.h"
#include "BotController.generated.h"


/**
 * 
 */
UCLASS()
class AITEST_API ABotController : public AAIController
{
	GENERATED_UCLASS_BODY()

	/** The black board component that stores all AI related Data */
	UPROPERTY(transient)
	TSubobjectPtr<class UBlackboardComponent> BlackboardComp;

	/** The Behaviour tree of the AI */
	UPROPERTY(transient)
		TSubobjectPtr<class UBehaviorTreeComponent> BehaviorComp;
		
	/** The posses function is called when the pawn is spawned to give the AI a control of the pawn */
	virtual void Possess(class APawn* InPawn) override;
	
};

.cpp

#include "AITest.h"
#include "BotController.h"


ABotController::ABotController(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	BlackboardComp = PCIP.CreateDefaultSubobject<UBlackboardComponent>(this, TEXT("BlackBoardComp"));
	BehaviorComp = PCIP.CreateDefaultSubobject<UBehaviorTreeComponent>(this, TEXT("BehaviorComp"));
}

void ABotController::Possess(APawn* InPawn)
{
	Super::Possess(InPawn);

}

Errors

1>  Reflection code generation finished for AITestEditor and took 5.586
1>  Performing 4 actions (max 2 parallel jobs)
1>  BotController.cpp
1>  AITest.generated.cpp
1>  [3/4] link.exe UE4Editor-HTML5TargetPlatform.dll
1>     Creating library D:\Unreal Engine\Engine\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-HTML5TargetPlatform.lib and object D:\Unreal Engine\Engine\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-HTML5TargetPlatform.exp
1>  [4/4] link.exe UE4Editor-AITest.dll
1>     Creating library C:\Users\Srikant\Documents\Unreal Projects\AITest\Intermediate\Build\Win64\AITestEditor\Development\UE4Editor-AITest.lib and object C:\Users\Srikant\Documents\Unreal Projects\AITest\Intermediate\Build\Win64\AITestEditor\Development\UE4Editor-AITest.exp
1>BotController.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl AAIController::AAIController(class FPostConstructInitializeProperties const &)" (__imp_??0AAIController@@QEAA@AEBVFPostConstructInitializeProperties@@@Z) referenced in function "public: __cdecl ABotController::ABotController(class FPostConstructInitializeProperties const &)" (??0ABotController@@QEAA@AEBVFPostConstructInitializeProperties@@@Z)
1>BotController.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void __cdecl AAIController::Possess(class APawn *)" (__imp_?Possess@AAIController@@UEAAXPEAVAPawn@@@Z) referenced in function "public: virtual void __cdecl ABotController::Possess(class APawn *)" (?Possess@ABotController@@UEAAXPEAVAPawn@@@Z)
1>BotController.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl AAIController::~AAIController(void)" (__imp_??1AAIController@@UEAA@XZ) referenced in function "int `public: __cdecl ABotController::ABotController(class FPostConstructInitializeProperties const &)'::`1'::dtor$0" (?dtor$0@?0???0ABotController@@QEAA@AEBVFPostConstructInitializeProperties@@@Z@4HA)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl AAIController::~AAIController(void)" (__imp_??1AAIController@@UEAA@XZ)
1>BotController.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl AAIController::AAIController(class AAIController const &)" (__imp_??0AAIController@@QEAA@AEBV0@@Z) referenced in function "public: __cdecl ABotController::ABotController(class ABotController const &)" (??0ABotController@@QEAA@AEBV0@@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl AAIController::AAIController(class AAIController const &)" (__imp_??0AAIController@@QEAA@AEBV0@@Z)
1>BotController.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class UClass * __cdecl UBlackboardComponent::StaticClass(void)" (__imp_?StaticClass@UBlackboardComponent@@SAPEAVUClass@@XZ) referenced in function "public: class UBlackboardComponent * __cdecl FPostConstructInitializeProperties::CreateDefaultSubobject<class UBlackboardComponent,class UBlackboardComponent>(class UObject *,class FName,bool,bool,bool)const " (??$CreateDefaultSubobject@VUBlackboardComponent@@V1@@FPostConstructInitializeProperties@@QEBAPEAVUBlackboardComponent@@PEAVUObject@@VFName@@_N22@Z)
1>BotController.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class UClass * __cdecl UBehaviorTreeComponent::StaticClass(void)" (__imp_?StaticClass@UBehaviorTreeComponent@@SAPEAVUClass@@XZ) referenced in function "public: class UBehaviorTreeComponent * __cdecl FPostConstructInitializeProperties::CreateDefaultSubobject<class UBehaviorTreeComponent,class UBehaviorTreeComponent>(class UObject *,class FName,bool,bool,bool)const " (??$CreateDefaultSubobject@VUBehaviorTreeComponent@@V1@@FPostConstructInitializeProperties@@QEBAPEAVUBehaviorTreeComponent@@PEAVUObject@@VFName@@_N22@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::ClearFocus(unsigned char)" (?ClearFocus@AAIController@@UEAAXE@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::ClearFocus(unsigned char)" (?ClearFocus@AAIController@@UEAAXE@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::DisplayDebug(class UCanvas *,class FDebugDisplayInfo const &,float &,float &)" (?DisplayDebug@AAIController@@UEAAXPEAVUCanvas@@AEBVFDebugDisplayInfo@@AEAM2@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::DisplayDebug(class UCanvas *,class FDebugDisplayInfo const &,float &,float &)" (?DisplayDebug@AAIController@@UEAAXPEAVUCanvas@@AEBVFDebugDisplayInfo@@AEAM2@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FString __cdecl AAIController::GetDebugIcon(void)const " (?GetDebugIcon@AAIController@@UEBA?AVFString@@XZ)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FString __cdecl AAIController::GetDebugIcon(void)const " (?GetDebugIcon@AAIController@@UEBA?AVFString@@XZ)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FVector __cdecl AAIController::GetFocalPoint(void)const " (?GetFocalPoint@AAIController@@UEBA?AVFVector@@XZ)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FVector __cdecl AAIController::GetFocalPoint(void)const " (?GetFocalPoint@AAIController@@UEBA?AVFVector@@XZ)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::GetPlayerViewPoint(class FVector &,class FRotator &)const " (?GetPlayerViewPoint@AAIController@@UEBAXAEAVFVector@@AEAVFRotator@@@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::GetPlayerViewPoint(class FVector &,class FRotator &)const " (?GetPlayerViewPoint@AAIController@@UEBAXAEAVFVector@@AEAVFRotator@@@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::GrabDebugSnapshot(struct FVisLogEntry *)const " (?GrabDebugSnapshot@AAIController@@UEBAXPEAUFVisLogEntry@@@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::GrabDebugSnapshot(struct FVisLogEntry *)const " (?GrabDebugSnapshot@AAIController@@UEBAXPEAUFVisLogEntry@@@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::InitNavigationControl(class UNavigationComponent * &,class UPathFollowingComponent * &)" (?InitNavigationControl@AAIController@@UEAAXAEAPEAVUNavigationComponent@@AEAPEAVUPathFollowingComponent@@@Z)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl AAIController::InitNavigationControl(class UNavigationComponent * &,class UPathFollowingComponent * &)" (?InitNavigationControl@AAIController@@UEAAXAEAPEAVUNavigationComponent@@AEAPEAVUPathFollowingComponent@@@Z) referenced in function "void __cdecl GetPrivateStaticClassBody<class AAITestCharacter>(wchar_t const *,wchar_t const *,class UClass * &,void (__cdecl*)(void))" (??$GetPrivateStaticClassBody@VAAITestCharacter@@@@YAXPEB_W0AEAPEAVUClass@@P6AXXZ@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl AAIController::LineOfSightTo(class AActor const *,class FVector,bool)const " (?LineOfSightTo@AAIController@@UEBA_NPEBVAActor@@VFVector@@_N@Z)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "public: virtual bool __cdecl AAIController::LineOfSightTo(class AActor const *,class FVector,bool)const " (?LineOfSightTo@AAIController@@UEBA_NPEBVAActor@@VFVector@@_N@Z) referenced in function "void __cdecl GetPrivateStaticClassBody<class AAITestCharacter>(wchar_t const *,wchar_t const *,class UClass * &,void (__cdecl*)(void))" (??$GetPrivateStaticClassBody@VAAITestCharacter@@@@YAXPEB_W0AEAPEAVUClass@@P6AXXZ@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::OnMoveCompleted(struct FAIRequestID,enum EPathFollowingResult::Type)" (?OnMoveCompleted@AAIController@@UEAAXUFAIRequestID@@W4Type@EPathFollowingResult@@@Z)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl AAIController::OnMoveCompleted(struct FAIRequestID,enum EPathFollowingResult::Type)" (?OnMoveCompleted@AAIController@@UEAAXUFAIRequestID@@W4Type@EPathFollowingResult@@@Z) referenced in function "class UPackage * __cdecl CastChecked<class UPackage>(class UObject *,enum ECastCheckedType::Type)" (??$CastChecked@VUPackage@@@@YAPEAVUPackage@@PEAVUObject@@W4Type@ECastCheckedType@@@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::PostInitializeComponents(void)" (?PostInitializeComponents@AAIController@@UEAAXXZ)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl AAIController::PostInitializeComponents(void)" (?PostInitializeComponents@AAIController@@UEAAXXZ) referenced in function "void __cdecl GetPrivateStaticClassBody<class AAITestGameMode>(wchar_t const *,wchar_t const *,class UClass * &,void (__cdecl*)(void))" (??$GetPrivateStaticClassBody@VAAITestGameMode@@@@YAXPEB_W0AEAPEAVUClass@@P6AXXZ@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FAIRequestID __cdecl AAIController::RequestMove(class TSharedPtr<struct FNavigationPath,1>,class AActor *,float,bool,class TSharedPtr<struct FMoveRequestCustomData,1>)" (?RequestMove@AAIController@@UEAA?AUFAIRequestID@@V?$TSharedPtr@UFNavigationPath@@$00@@PEAVAActor@@M_NV?$TSharedPtr@UFMoveRequestCustomData@@$00@@@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FAIRequestID __cdecl AAIController::RequestMove(class TSharedPtr<struct FNavigationPath,1>,class AActor *,float,bool,class TSharedPtr<struct FMoveRequestCustomData,1>)" (?RequestMove@AAIController@@UEAA?AUFAIRequestID@@V?$TSharedPtr@UFNavigationPath@@$00@@PEAVAActor@@M_NV?$TSharedPtr@UFMoveRequestCustomData@@$00@@@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::Reset(void)" (?Reset@AAIController@@UEAAXXZ)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::Reset(void)" (?Reset@AAIController@@UEAAXXZ)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl AAIController::RunBehaviorTree(class UBehaviorTree *)" (?RunBehaviorTree@AAIController@@UEAA_NPEAVUBehaviorTree@@@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl AAIController::RunBehaviorTree(class UBehaviorTree *)" (?RunBehaviorTree@AAIController@@UEAA_NPEAVUBehaviorTree@@@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::SetFocalPoint(class FVector,bool,unsigned char)" (?SetFocalPoint@AAIController@@UEAAXVFVector@@_NE@Z)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl AAIController::SetFocalPoint(class FVector,bool,unsigned char)" (?SetFocalPoint@AAIController@@UEAAXVFVector@@_NE@Z) referenced in function "class UClass * __cdecl Z_Construct_UClass_ABotController(void)" (?Z_Construct_UClass_ABotController@@YAPEAVUClass@@XZ)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::SetFocus(class AActor *,unsigned char)" (?SetFocus@AAIController@@UEAAXPEAVAActor@@E@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::SetFocus(class AActor *,unsigned char)" (?SetFocus@AAIController@@UEAAXPEAVAActor@@E@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::StopMovement(void)" (?StopMovement@AAIController@@UEAAXXZ)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::StopMovement(void)" (?StopMovement@AAIController@@UEAAXXZ)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::Tick(float)" (?Tick@AAIController@@UEAAXM@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::Tick(float)" (?Tick@AAIController@@UEAAXM@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::UnPossess(void)" (?UnPossess@AAIController@@UEAAXXZ)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::UnPossess(void)" (?UnPossess@AAIController@@UEAAXXZ)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::UpdateControlRotation(float,bool)" (?UpdateControlRotation@AAIController@@UEAAXM_N@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AAIController::UpdateControlRotation(float,bool)" (?UpdateControlRotation@AAIController@@UEAAXM_N@Z)
1>BotController.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl AAIController::UseBlackboard(class UBlackboardData *)" (?UseBlackboard@AAIController@@UEAA_NPEAVUBlackboardData@@@Z)
1>AITest.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl AAIController::UseBlackboard(class UBlackboardData *)" (?UseBlackboard@AAIController@@UEAA_NPEAVUBlackboardData@@@Z)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_AAIController(void)" (__imp_?Z_Construct_UClass_AAIController@@YAPEAVUClass@@XZ) referenced in function "class UClass * __cdecl Z_Construct_UClass_ABotController(void)" (?Z_Construct_UClass_ABotController@@YAPEAVUClass@@XZ)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class UClass * __cdecl AAIController::StaticClass(void)" (__imp_?StaticClass@AAIController@@SAPEAVUClass@@XZ) referenced in function "void __cdecl GetPrivateStaticClassBody<class ABotController>(wchar_t const *,wchar_t const *,class UClass * &,void (__cdecl*)(void))" (??$GetPrivateStaticClassBody@VABotController@@@@YAXPEB_W0AEAPEAVUClass@@P6AXXZ@Z)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UBehaviorTreeComponent_NoRegister(void)" (__imp_?Z_Construct_UClass_UBehaviorTreeComponent_NoRegister@@YAPEAVUClass@@XZ) referenced in function "class UClass * __cdecl Z_Construct_UClass_ABotController(void)" (?Z_Construct_UClass_ABotController@@YAPEAVUClass@@XZ)
1>AITest.generated.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UBlackboardComponent_NoRegister(void)" (__imp_?Z_Construct_UClass_UBlackboardComponent_NoRegister@@YAPEAVUClass@@XZ) referenced in function "class UClass * __cdecl Z_Construct_UClass_ABotController(void)" (?Z_Construct_UClass_ABotController@@YAPEAVUClass@@XZ)
1>C:\Users\Srikant\Documents\Unreal Projects\AITest\Binaries\Win64\UE4Editor-AITest.dll : fatal error LNK1120: 30 unresolved externals
1>  -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\Srikant\Documents\Unreal Projects\AITest\Binaries\Win64\UE4Editor-AITest.dll
1>  Cumulative action seconds (4 processors): 0.00 building projects, 3.82 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.87 linking, 0.00 other
1>  UBT execution time: 29.45 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""D:\Unreal Engine\Engine\Build\BatchFiles\Build.bat" AITestEditor Win64 Development "C:\Users\Srikant\Documents\Unreal Projects\AITest\AITest.uproject"" exited with code -1.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Edit… I think the bug comes when I use the AI controller file.

Not related to other things.

Looks like you’re missing AIModule as one of your project’s dependencies.

–mieszko

1 Like

PublicDependencyModuleNames.AddRange(new string[] { “Core”, “CoreUObject”, “Engine”, “InputCore” }); Just have this

Worked… Thanks…