Keywords: UE4, Plugin, LNK2019, GetPrivateStaticClass

UE4 Plugin Link Error:

Error    LNK2019    unresolved external symbol "private: static class UClass * __cdecl UMyComponent::GetPrivateStaticClass(void)" (?GetPrivateStaticClass@UMyComponent@@CAPEAVUClass@@XZ) referenced in function "class UMyComponent * __cdecl NewObject<class UMyComponent>(class UObject *)" (??$NewObject@VUMyComponent@@@@YAPEAVUMyComponent@@PEAVUObject@@@Z)    ClimbWall
Case 1:

Maybe you removed UE4’s macro in your headers.

Solution:
Add UE4 stylized macro MYPLUGIN_API in headers, e.g.:

UCLASS()
class MYPLUGIN_API UMyComponent : public UActorComponent
{
    GENERATED_BODY()
}

Ensure all headers of your plugin have been added macro MYPLUGIN_API(even raw classes), otherwise there’s a compilication error LNK2019 if your plugin header was included in other Modules or game project.

Case 2:

Maybe you included a header in your project, but didn’t include module name of header in .Build.cs.
e.g., you included Editor.h, but you didn’t add UnrealEd into PrivateDependencyModuleNames in [YourProj].Build.cs.

PrivateDependencyModuleNames.AddRange(
new string[]
{
    "CoreUObject",
    "Engine",
    "Slate",
    "SlateCore",
    "UnrealEd"
}
);
Case 3:

Maybe you declare a function but the defination lost.
example:

void fun01();

void AMyActor::BeginPlay()
{
    ...
    fun01();
    ...
}
Case 4:

Maybe you forgot to include the module name when you include headers of other module.

Project structure:

MyGame
    |---Source
          |---MyGame
          |     ---MyGame.Build.cs
          |     ---MyActor.h
          |     ---MyActor.cpp
          |---MyGameEditor
                ---MyGameEditor.Build.cs
                |---Public
                |     ---MyGameEditorModule.h
                |     ---MyBlueprintLibrary.h
                |---Private
                      ---MyBlueprintLibrary.cpp

MyBlueprintLibrary.cpp

#include "MyGame/MyActor.h"

If module (MyGame) missed Public and Private direcotry, then include headers (MyActor.h) of this module without module name: #include "MyActor.h", it results LNK2019 error.