1. Home
  2. UE5 Compilation Errors
  3. UE5 C++ Compilation Error...
  4. LNK2001: UE5 Unresolved External Symbol

LNK2001: UE5 Unresolved External Symbol

What It Means & How to Fix It in UE5 C++


🧠 Why You’re Seeing This Error

LNK2001 means the compiler found a reference to a function or variable — but couldn’t find its definition during linking. It’s like saying:

“You declared this thing, but you never actually wrote the code for it.”

In UE5, this usually happens when:

  • You declare a function in a .h but forget to define it in your .cpp
  • You declare a global/static variable but don’t initialize it anywhere
  • You reference a BlueprintCallable function from C++ that isn’t implemented
  • You’re missing an external module or plugin dependency in your *.Build.cs file

💥 Example Error Message

LNK2001: unresolved external symbol "public: void AMyActor::DoSomething(void)"

🛠️ Example Code

// In MyActor.h
UCLASS()
class AMyActor : public AActor
{
GENERATED_BODY()

public:
void DoSomething(); // ✅ Declared
};
// In MyGameMode.cpp
AMyActor* Actor = GetWorld()->SpawnActor();
Actor->DoSomething(); // ❌ LNK2001: Function not linked

But… the definition for DoSomething() was never written.


✅ How to Fix LNK2001 in UE5 – Step-by-Step


✔️ 1. Define the Function in Your .cpp File

Fix:

void AMyActor::DoSomething()
{
// Your logic here
}

✔️ 2. If You Declare a Variable, Define It Somewhere

Wrong:

// MyGlobals.h
int32 MyScore; // ❌ Causes LNK2001 if not defined

Fix:

// MyGlobals.cpp
int32 MyScore = 0; // ✅ One definition

✔️ 3. Ensure You Linked Required Modules in .Build.cs

If you’re calling into another UE5 module or plugin, add it to your dependencies:

csharpCopyEditPublicDependencyModuleNames.AddRange(new string[] { "Core", "Engine", "AIModule" });

✔️ 4. Check Spelling and Signature Mismatches

A declaration like void DoSomething(int32 Amount); won’t match a definition like void DoSomething(float Amount); — and LNK2001 will hit.


✅ Summary: How to Fix LNK2001 in UE5

CauseFix Example
Function declared but not definedWrite its body in the .cpp file
Variable declared globally but undefinedDefine it in one .cpp file
Missing module in .Build.csAdd required dependency modules
Declaration/definition mismatchEnsure types and parameter count match exactly
Was this article helpful to you? Yes No

How can we help?