ADetourCrowdAIController in C++

I want to inherit my ai controller form ADetourCrowdAIController, but error LNK2019 happens.

AIModule has been added to the project settings(both .build.cs and .uproject), but error still exists, does anyone know how to solve this?

UCLASS()
class WOP_API AWOP_AIController_Base: public ADetourCrowdAIController

1>WOP_AIController_Base.cpp.obj : error LNK2019: 无法解析的外部符号 “public: __cdecl ADetourCrowdAIController::ADetourCrowdAIController(class FObjectInitializer const &)” (??0ADetourCrowdAIController@@QEAA@AEBVFObjectInitializer@@@Z),该符号在函数 “public: __cdecl AWOP_AIController_Base::AWOP_AIController_Base(class FObjectInitializer const &)” (??0AWOP_AIController_Base@@QEAA@AEBVFObjectInitializer@@@Z) 中被引用
1>WOP2.generated.cpp.obj : error LNK2019: 无法解析的外部符号 “private: static class UClass * __cdecl ADetourCrowdAIController::GetPrivateStaticClass(wchar_t const *)” (?GetPrivateStaticClass@ADetourCrowdAIController@@CAPEAVUClass@@PEB_W@Z),该符号在函数 “public: static class UClass * __cdecl ADetourCrowdAIController::StaticClass(void)” (?StaticClass@ADetourCrowdAIController@@SAPEAVUClass@@XZ) 中被引用
1>WOP2.generated.cpp.obj : error LNK2019: 无法解析的外部符号 “public: __cdecl ADetourCrowdAIController::ADetourCrowdAIController(class FVTableHelper &)” (??0ADetourCrowdAIController@@QEAA@AEAVFVTableHelper@@@Z),该符号在函数 “public: __cdecl AWOP_AIController_Base::AWOP_AIController_Base(class FVTableHelper &)” (??0AWOP_AIController_Base@@QEAA@AEAVFVTableHelper@@@Z) 中被引用

but when I tried the shipping settings in VS, the build was successful.

1 Like

I have found a another way. Instead of inheriting from ADetourCrowdAIController, I add : Super(ObjectInitializer.SetDefaultSubobjectClass<UCrowdFollowingComponent>(TEXT(“PathFollowingComponent”))) to my constructor.

FCrowdAvoidanceConfig | Unreal Engine Documentation.

1 Like

I realise this post is from a while back and you found an alternative, but if anyone else comes across it the reason for the link errors is that ADetourCrowdAIController is missing the AI Module API macro in it’s header:

class AIMODULE_API ADetourCrowdAIController : public AAIController

So how would I fix it ?

I too have this issue. haisong’s workaround appears to work, but an actual fix appears to be to add the missing AIMODULE_API macro in the engine source. It is still missing as of 4.21.1.

Using the super constructor to override the PathFollowingComponent in the base class the way haisong has done is not a workaround but the way it was meant be done.

1 Like

Why would anyone desire for you to reinvent the wheel when you can just make a child class?

I found this thread when converting to 4.23. I did have my AIController inheriting from ADetourCrowdAIController and could no longer compile. I did the following but it doesn’t work. I admit that I don’t understand syntactically how to make this work. Could someone comment on what I might have wrong here:

  1. I changed the inheritance in my h file to inherit only from AAIController and added my constructor with the FObjectInitializer as follows:

UCLASS()

class NEVERMEMORY_API AFPSAIController : public AAIController //ADetourCrowdAIController 

{

    GENERATED_BODY()

    AFPSAIController(const FObjectInitializer& ObjectInitializer);



  1. I put in a new constructor as follows:

AFPSAIController::AFPSAIController(const FObjectInitializer& ObjectInitializer)

: Super(ObjectInitializer.SetDefaultSubobjectClass<UCrowdFollowingComponent>(TEXT("PathFollowingComponent"))) {

}


  1. I added in the include file as “#include Navigation/CrowdManager.h”

After this I now get a compiler error from a macro in the engine source of:

Incomplete definition of type ‘UCrowdFollowingComponent’
Incomplete type ‘UCrowdFollowingComponent’ named in nested name specifier

Being lost here, I’m wondering if someone could tell me what I’ve done wrong, I’ve attempted to follow what the documentation states as noted above in haisong’s link.

1 Like

#include "Navigation/CrowdFollowingComponent.h"

1 Like

Thank you very much. That did the trick and it compiles now.