Not able to rectify the error

Hello, I don’t know what’s the error here. It is showing no errors but the build fails.

Here’s the build log:

Build started...
1>------ Build started: Project: MyBG, Configuration: DebugGame_Editor x64 ------
1>Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" MyBGEditor Win64 DebugGame -Project="C:\Users\Ranju\Documents\Unreal Projects\MyBG\MyBG.uproject" -WaitMutex -FromMsBuild
1>Log file: C:\Users\Ranju\AppData\Local\UnrealBuildTool\Log.txt
1>Building MyBGEditor...
1>Using Visual Studio 2022 14.33.31631 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629) and Windows 10.0.22621.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Determining max actions to execute in parallel (8 physical cores, 16 logical cores)
1>  Executing up to 8 processes, one per physical core
1>Building 2 actions with 2 processes...
1>[1/2] Link UnrealEditor-MyBG-Win64-DebugGame.dll
1>BaseAirdrop.cpp.obj : error LNK2005: "public: void __cdecl ABaseAirdrop::Multi_StartMovingZone(void)" (?Multi_StartMovingZone@ABaseAirdrop@@QEAAXXZ) already defined in BaseAirdrop.gen.cpp.obj
1>   Creating library C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\DebugGame\MyBG\UnrealEditor-MyBG-Win64-DebugGame.suppressed.lib and object C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\DebugGame\MyBG\UnrealEditor-MyBG-Win64-DebugGame.suppressed.exp
1>BaseAirdrop.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl ABaseAirdrop::Multi_StartMovingZone_Implementation(void)" (?Multi_StartMovingZone_Implementation@ABaseAirdrop@@UEAAXXZ)
1>BaseAirdrop.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl ABaseAirdrop::Multi_StartMovingZone_Implementation(void)" (?Multi_StartMovingZone_Implementation@ABaseAirdrop@@UEAAXXZ)
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Binaries\Win64\UnrealEditor-MyBG-Win64-DebugGame.dll : fatal error LNK1120: 1 unresolved externals
1>[2/2] WriteMetadata MyBGEditor-Win64-DebugGame.target cancelled
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "D:\UE_5.1\Engine\Build\BatchFiles\Build.bat MyBGEditor Win64 DebugGame -Project="C:\Users\Ranju\Documents\Unreal Projects\MyBG\MyBG.uproject" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "MyBG.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 3:35 PM and took 02.006 seconds ==========

Here’s the code:

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


#include "BaseAirdrop.h"

// Sets default values
ABaseAirdrop::ABaseAirdrop()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	bReplicates = true;
	SetReplicateMovement(true);
	ZoneMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Zone Mesh"));
	SetRootComponent(ZoneMesh);

}

// Called when the game starts or when spawned
void ABaseAirdrop::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void ABaseAirdrop::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void ABaseAirdrop::Multi_StartMovingZone()
{
	if (ZoneMesh)
	{
		FVector LocalVector;
		LocalVector = FVector(ZoneMesh->GetComponentScale().X - ScaleToDecrease, ZoneMesh->GetComponentScale().Y - ScaleToDecrease, ZoneMesh->GetComponentScale().Z - ScaleToDecrease);
		ZoneMesh->SetRelativeScale3D(LocalVector);
	}
	else
	{
		UE_LOG(LogTemp, Error, TEXT("Zone Mesh not valid"));
	}
}

void ABaseAirdrop::StartMovingZone_Implementation()
{
	GetWorld()->GetTimerManager().SetTimer(MovingTimerHandle, this, &ABaseAirdrop::Multi_StartMovingZone, 0.01f, true);
}


What should I do?

in your code you can see (the red zone) comment problems.

#include "BaseAirdrop.h"

// Sets default values
ABaseAirdrop::ABaseAirdrop()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you dont need it.  
	PrimaryActorTick.bCanEverTick = true;
	bReplicates = true;
	SetReplicateMovement(true);
	ZoneMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Zone Mesh"));
	SetRootComponent(ZoneMesh);

}

// Called when the game starts or when spawned
void ABaseAirdrop::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void ABaseAirdrop::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void ABaseAirdrop::Multi_StartMovingZone()
{
	if (ZoneMesh)
	{
		FVector LocalVector;
		LocalVector = FVector(ZoneMesh->GetComponentScale().X - ScaleToDecrease, ZoneMesh->GetComponentScale().Y - ScaleToDecrease, ZoneMesh->GetComponentScale().Z - ScaleToDecrease);
		ZoneMesh->SetRelativeScale3D(LocalVector);
	}
	else
	{
		UE_LOG(LogTemp, Error, TEXT("Zone Mesh not valid"));
	}
}

void ABaseAirdrop::StartMovingZone_Implementation()
{
	GetWorld()->GetTimerManager().SetTimer(MovingTimerHandle, this, &ABaseAirdrop::Multi_StartMovingZone, 0.01f, true);
}

maybe is that?

I don’t know how to solve it but, here’s the main error from the log :

1>BaseAirdrop.cpp.obj : error LNK2005: "public: void __cdecl ABaseAirdrop::Multi_StartMovingZone(void)" (?Multi_StartMovingZone@ABaseAirdrop@@QEAAXXZ) already defined in BaseAirdrop.gen.cpp.obj

It says Multi_StartMovingZone is already defined in BaseAirdrop.gen.cpp.obj

Since BaseAirdrop.gen.cpp.obj is auto generated, my best guess would be to check the UFUNCTION() of Multi_StartMovingZone in your header file.

Hello guys, thank you for the reply, I have figured it out.

It is a silly mistake.
I was supposed to write void ABaseAirdrop::Multi_StartMovingZone_Implementation()
instead of void ABaseAirdrop::Multi_StartMovingZone()

1 Like