I have a fairly simple function I just started writing inside an actor component:
void Uai_patrol_cpp::NextPatrolNode()
{
APawn* pawn = Cast<APawn>(GetOwner());
AController* controller = pawn->GetController();
AAIController* aiController = Cast<AAIController, AController>(controller);
}
The third line with the cast is causing UE5 to throw on compile like so:
ai_patrol_cpp.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class UClass * __cdecl AAIController::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@AAIController@@CAPEAVUClass@@XZ) referenced in function "protected: void __cdecl Uai_patrol_cpp::NextPatrolNode(void)" (?NextPatrolNode@Uai_patrol_cpp@@IEAAXXZ)
Hint on symbols that are defined and could potentially match:
"__declspec(dllimport) private: static class UClass * __cdecl APawn::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@APawn@@CAPEAVUClass@@XZ)
"__declspec(dllimport) private: static class UClass * __cdecl UCameraComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UCameraComponent@@CAPEAVUClass@@XZ)
"__declspec(dllimport) private: static class UClass * __cdecl UInputSettings::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UInputSettings@@CAPEAVUClass@@XZ)
"__declspec(dllimport) private: static class UClass * __cdecl UObject::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UObject@@CAPEAVUClass@@XZ)
"__declspec(dllimport) private: static class UClass * __cdecl UProjectileMovementComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UProjectileMovementComponent@@CAPEAVUClass@@XZ)
"__declspec(dllimport) private: static class UClass * __cdecl USkeletalMeshComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@USkeletalMeshComponent@@CAPEAVUClass@@XZ)
"__declspec(dllimport) private: static class UClass * __cdecl USphereComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@USphereComponent@@CAPEAVUClass@@XZ)
If the pawn’s AController isn’t an AAIController (though I can’t imagine why it wouldn’t be), I would expect it to throw on a bad cast and not a linker error. It sounds to me like it’s saying Cast() is trying to call GetPrivateStaticClass() and it’s an ambiguous reference. Since I’m not the one calling GetPrivateStaticClass(), I’m not sure what it wants from me to fix that.
I tried deleting the ‘Intermediate’ folder and regenerating the VS project thinking that would shake something loose, but no.
Has anyone else run into this? Am I simply missing an include somewhere?