Weird warning LNK4006 & LNK2005 compiling errors

Upon including the .h of another class in my controller, I get these errors:

image

warning LNK4006: “protected: virtual void __cdecl ACBPlayerController::BeginPlay(void)” (?BeginPlay@ACBPlayerController@@MEAAXXZ) already defined in CBCarriageActor.cpp.obj; second definition ignored

image

error LNK2005: “protected: virtual void __cdecl ACBPlayerController::BeginPlay(void)” (?BeginPlay@ACBPlayerController@@MEAAXXZ) already defined in CBCarriageActor.cpp.obj

If i remove the .h the error disappears, but I can’t understand why this error is happening. Does anyone know?

I had a similar error too. I had a blueprint implementable function declared in the .h file of my actor and a function defined in the .cpp like below.

void AActor::Function(float f)
{
return;
}
I removed the above function from the cpp file and it built successfully

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.