I am on section 5 lecture 320.
When I try to compile the code using Unreal engine 4.21.1, I get this linker error
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol “__declspec(dllimport) private: static class UClass * __cdecl ANavMeshBoundsVolume::GetPrivateStaticClass(void)” (_imp?GetPrivateStaticClass@ANavMeshBoundsVolume@@CAPEAVUClass@@XZ) referenced in function “public: void __cdecl AInfiniteTerrainGameMode::PopulateBoundsVolumePool(void)” (?PopulateBoundsVolumePool@AInfiniteTerrainGameMode@@QEAAXXZ) TestingGrounds Documents\Unreal Projects\TestingGrounds\Intermediate\ProjectFiles\InfiniteTerrainGameMode.cpp.obj 1
Here is the list of things I have tried numerous times
- Delete binary, intermediate and saved and .sln file, regenerate everything.
- Adding this line to my TestingGrounds.target.cs and TestingGroundsEditor.Target.cs
ExtraModuleNames.AddRange(new string { “TestingGrounds”, “NavigationSystem”,“AIModule”, “Navmesh” }); - Re parenting my game mode class to the testing grounds one, then deleting the InfiniteTerrainGameMode c++ file and header, regenerating game files
- Adding various header files, include Engine.h just to try to get it to work
I have found the actual Function that is causing the problem
void AInfiniteTerrainGameMode::PopulateBoundsVolumePool()
{
// The line below is causing the problem
auto VolumeIterator = TActorIterator<ANavMeshBoundsVolume>(GetWorld());
//TActorIterator<ANavMeshBoundsVolume> VolumeIterator = TActorIterator<ANavMeshBoundsVolume *>(GetWorld());
TArray<ANavMeshBoundsVolume> *NavMesh = NULL;
/*
while (VolumeIterator)
{
AddToPool(*VolumeIterator);
++VolumeIterator;
}
*/
}
comment out that line and it compiles fine.
Tried using this in its place
TArray<AActor *> found;
UGameplayStatics::GetAllActorsOfClass(GetWorld(),ANavMeshBoundsVolume::StaticClass(), found);
Got the exact same linker error.
I tried adding this to my InfiniteTerrainGameMode.cpp file and override in the header
void AInfiniteTerrainGameMode::PostRegisterAllComponents()
{
Super::PostRegisterAllComponents();
}
Here are both files in their entirety
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include “TestingGroundsGameMode.h”
#include “NavigationSystem/Public/NavMesh/NavMeshBoundsVolume.h”
#include “Classes/AISystem.h”
#include “InfiniteTerrainGameMode.generated.h”
/**
*
*/
UCLASS()
class TESTINGGROUNDS_API AInfiniteTerrainGameMode : public ATestingGroundsGameMode
{
GENERATED_BODY()
public:
AInfiniteTerrainGameMode();
//UFUNCTION(BlueprintCallable, Category = "Bounds Pool")
void PopulateBoundsVolumePool();
void PostRegisterAllComponents() override;
protected:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = “Pool”)
class UActorPool* NavMeshBoundsVolumePool;
private:
void AddToPool(ANavMeshBoundsVolume *VolumeToAdd);
};
cpp file
// Fill out your copyright notice in the Description page of Project Settings.
#include “InfiniteTerrainGameMode.h”
#include “TestingGrounds.h”
#include “NavigationSystem/Public/NavMesh/NavMeshBoundsVolume.h”
#include “Classes/AISystem.h”
#include “EngineUtils.h”
#include “ActorPool.h”
#include “GameFramework/Actor.h”
#include “Kismet/GameplayStatics.h”
AInfiniteTerrainGameMode::AInfiniteTerrainGameMode()
{
NavMeshBoundsVolumePool = CreateDefaultSubobject(FName(“Nav Mesh Bounds Volume Pool”));
}
void AInfiniteTerrainGameMode::PopulateBoundsVolumePool()
{
//TArray<AActor *> found;
//UGameplayStatics::GetAllActorsOfClass(GetWorld(),ANavMeshBoundsVolume::StaticClass(), found);
auto VolumeIterator = TActorIterator(GetWorld());
//TActorIterator VolumeIterator = TActorIterator<ANavMeshBoundsVolume *>(GetWorld());
//TArray NavMesh = NULL;
/
while (VolumeIterator)
{
AddToPool(*VolumeIterator);
++VolumeIterator;
}
*/
}
void AInfiniteTerrainGameMode::AddToPool(ANavMeshBoundsVolume *VolumeToAdd)
{
NavMeshBoundsVolumePool->Add(VolumeToAdd);
}
void AInfiniteTerrainGameMode::PostRegisterAllComponents()
{
Super::PostRegisterAllComponents();
}
Please help, I am unable to continue the course without this error being resolved. Oh, I also tried copying and pasting both the cpp and header files from github for testing grounds, which produced the exact same error.