Why do I get a LNK error for GetLifetimeReplicatedProps() in a class that does not use that function?

Why do I get a LNK error for GetLifetimeReplicatedProps() in a class that does not use that function?

Even stranger, if I ignore the error and just compile again it says:

1>  Compiling game modules for hot reload
1>  Target is up to date.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Is the second compile really a successful compile?

I had this problem too,in my case it happens when an UPROPERTY has the “REPLICATED” flag on it.

How To Fix It:

In Your .h :

UPROPERTY(replicated)
AYourActorClass* ClassOwner;

In Your .cpp :

void AYourClassName::GetLifetimeReplicatedProps( TArray< FLifetimeProperty > & OutLifetimeProps ) const
{
    DOREPLIFETIME(AYourActorClass, ClassOwner);
}

Hope this solves your problem. I Kinda guess this function is needed for replication.