OnComponentBeginOverlap linker error

In order for the compiler to tell the difference between a call to the BeginOverlap() function and the function itself, you must implement the function (in the .cpp file) as BeginOverlap_Implementation(). This is because it is specified to be “BlueprintNative”. Change the function name in the cpp file and see how that goies.

Don’t feel bad. Linking blueprints and C++ isn’t standard so there’s a learning curve for everyone. GL!

Please close out your question by marking my answer (check box on the upper-left).

I’m following the unreal engine scripting cookbook and i’m stucked doing a simple overlapping test.
The problem seems to be in a cycle collecting code but I can’t find where it comes.
Here is code and error log: item.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/SphereComponent.h"
#include "Item.generated.h"

UCLASS()
class CODINGTEST_API AItem : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AItem();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	virtual void PostInitializeComponents() override;

	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category=collision)
		USphereComponent* sphere;

	UFUNCTION(BlueprintNativeEvent, Category = collision)
		void BeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult);
	
};

item.cpp

#include "Item.h"


// Sets default values
AItem::AItem()
{
 	// 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;
	sphere = CreateDefaultSubobject<USphereComponent>(TEXT("sphere"));
	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("root"));
	sphere->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
}

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

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

}

void AItem::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	sphere->OnComponentBeginOverlap.AddDynamic(this, &AItem::BeginOverlap);
}

void AItem::BeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
{
	UE_LOG(LogTemp, Warning, TEXT("overlaps item begin"));
}

and the error log:

2>Item.gen.cpp.obj : error LNK2005: "public: void __cdecl AItem::BeginOverlap(class UPrimitiveComponent *,class AActor *,class UPrimitiveComponent *,int,bool,struct FHitResult const &)" (?BeginOverlap@AItem@@QEAAXPEAVUPrimitiveComponent@@PEAVAActor@@0H_NAEBUFHitResult@@@Z) already defined in Item.cpp.obj
2>   Creating library E:\Mesdocuments\Unreal Projects\CodingTest\Binaries\Win64\CodingTest-Win64-DebugGame.lib and object E:\Mesdocuments\Unreal Projects\CodingTest\Binaries\Win64\CodingTest-Win64-DebugGame.exp
2>Item.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AItem::BeginOverlap_Implementation(class UPrimitiveComponent *,class AActor *,class UPrimitiveComponent *,int,bool,struct FHitResult const &)" (?BeginOverlap_Implementation@AItem@@UEAAXPEAVUPrimitiveComponent@@PEAVAActor@@0H_NAEBUFHitResult@@@Z)
2>Item.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AItem::BeginOverlap_Implementation(class UPrimitiveComponent *,class AActor *,class UPrimitiveComponent *,int,bool,struct FHitResult const &)" (?BeginOverlap_Implementation@AItem@@UEAAXPEAVUPrimitiveComponent@@PEAVAActor@@0H_NAEBUFHitResult@@@Z)
2>E:\Mesdocuments\Unreal Projects\CodingTest\Binaries\Win64\CodingTest-Win64-DebugGame.exe : fatal error LNK1120: 1 unresolved externals

Thanks…
Spent 3hours trying to fix this and you save my night in a single word… :slight_smile:
I come from c# and unity and really, unreal is f***** hard to learn.
I can’t count the hours spent to fix error like this…