Building C++ Blueprint function returns error LNK2019: unresolved external symbol

Hello all,

I am trying to build a blueprint function where I can set various parts of the AIPerception component. However when building the code Visual C respons with: error LNK2019: unresolved external symbol

Header file
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Perception/AISense.h"
#include "Perception/AISenseConfig.h"
#include "Perception/AIPerceptionTypes.h"
#include "Perception/AISenseConfig_Sight.h"
#include "Perception/AIPerceptionComponent.h"
#include "GameUtils.generated.h"

/**
 * 
 */
UCLASS()
class GHOSTTOWN2021_API UGameUtils : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	UFUNCTION(BlueprintCallable, Category = "AIPerception|Sight")
		static bool SetSightRange(UAIPerceptionComponent *Perception, float SightRange);
};

Test building it with a fake function only returning true ends with the unresolved symbol error, see below.

1>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
1>Project not selected to build for this solution configuration 
2>------ Build started: Project: GhostTown2021, Configuration: Development_Editor x64 ------
2>Creating makefile for GhostTown2021Editor (ini files are newer than makefile)
2>Parsing headers for GhostTown2021Editor
2>  Running UnrealHeaderTool "E:\GameDesign\Unreal\Projects\GhostTown2021\GhostTown2021.uproject" "E:\GameDesign\Unreal\Projects\GhostTown2021\Intermediate\Build\Win64\GhostTown2021Editor\Development\GhostTown2021Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
2>Reflection code generated for GhostTown2021Editor in 4,6975623 seconds
2>Using Visual Studio 2017 14.16.27023 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023) and Windows 10.0.16299.0 SDK (C:\Program Files (x86)\Windows Kits\10).
2>Building 6 actions with 6 processes...
2>  [1/6] GhostTown2021.init.gen.cpp
2>  [2/6] GameUtils.cpp
2>  [3/6] GameUtils.gen.cpp
2>  [4/6] UE4Editor-GhostTown2021-0026.lib
2>     Creating library E:\GameDesign\Unreal\Projects\GhostTown2021\Intermediate\Build\Win64\UE4Editor\Development\GhostTown2021\UE4Editor-GhostTown2021-0026.lib and object E:\GameDesign\Unreal\Projects\GhostTown2021\Intermediate\Build\Win64\UE4Editor\Development\GhostTown2021\UE4Editor-GhostTown2021-0026.exp
2>  [5/6] UE4Editor-GhostTown2021-0026.dll
2>     Creating library E:\GameDesign\Unreal\Projects\GhostTown2021\Intermediate\Build\Win64\UE4Editor\Development\GhostTown2021\UE4Editor-GhostTown2021-0026.suppressed.lib and object E:\GameDesign\Unreal\Projects\GhostTown2021\Intermediate\Build\Win64\UE4Editor\Development\GhostTown2021\UE4Editor-GhostTown2021-0026.suppressed.exp
2>GameUtils.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UAIPerceptionComponent_NoRegister(void)" (__imp_?Z_Construct_UClass_UAIPerceptionComponent_NoRegister@@YAPEAVUClass@@XZ) referenced in function "void __cdecl `dynamic initializer for 'public: static struct UE4CodeGen_Private::FObjectPropertyParams const Z_Construct_UFunction_UGameUtils_SetSightRange_Statics::NewProp_Perception''(void)" (??__E?NewProp_Perception@Z_Construct_UFunction_UGameUtils_SetSightRange_Statics@@2UFObjectPropertyParams@UE4CodeGen_Private@@B@@YAXXZ)
2>E:\GameDesign\Unreal\Projects\GhostTown2021\Binaries\Win64\UE4Editor-GhostTown2021-0026.dll : fatal error LNK1120: 1 unresolved externals
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""D:\GameDesign\Epic Games\UE_4.22\Engine\Build\BatchFiles\Build.bat" GhostTown2021Editor Win64 Development -Project="E:\GameDesign\Unreal\Projects\GhostTown2021\GhostTown2021.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
2>Done building project "GhostTown2021.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

When I remove the UAIPerceptionComponent everything builds fine.

Do I have to include a library or am I missing something? Help is very much appreciated.

I am using 4.22 and Visual Studio Community 2017.

Thanks
Richard.

Solved it.

I had to add the AI modules to the Dependency part of the project build.cs file.

// Fill out your copyright notice in the Description page of Project Settings.

using UnrealBuildTool;

public class GhostTown2021 : ModuleRules
{
	public GhostTown2021(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
	
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AIModule", "AISupportModule" });

		PrivateDependencyModuleNames.AddRange(new string[] {  });

		// Uncomment if you are using Slate UI
		// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
		
		// Uncomment if you are using online features
		// PrivateDependencyModuleNames.Add("OnlineSubsystem");

		// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
	}
}