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

LNK2001: Unresolved External Symbol in UE5

What It Means & How to Fix It


🧠 Why You’re Seeing This Error

The LNK2001 error means the linker found a reference to a variable or function, but it couldn’t find its definition anywhere in the compiled code.

This is similar to LNK2019, but LNK2001 usually points to global/static variables, class members, or template instances rather than functions.

In UE5, this happens when:

  • You declare a variable or function in a header but never define it
  • You define a static variable inside a class but forget the .cpp side
  • You reference something that’s only declared inline
  • You’re using templates improperly or across modules without full definitions

💥 Example Error Message

LNK2001: unresolved external symbol "private: static int32 AMyActor::Counter"

🛠️ Example Code

// MyActor.h

UCLASS()
class AMyActor : public AActor
{
GENERATED_BODY()

static int32 Counter; // ❌ Declared but not defined
};
// MyActor.cpp

// ❌ Missing definition of AMyActor::Counter

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


✔️ 1. Define Static Class Variables in the .cpp File

Fix:

// MyActor.cpp
int32 AMyActor::Counter = 0; // ✅ Defined

Without this, the linker has nowhere to find storage for that static variable.


✔️ 2. Don’t Declare Functions Without Defining Them

Same as with LNK2019 — just declaring a function isn’t enough.

Wrong:

void DoSomething(); // declared in header
// ❌ But never defined in cpp

Fix:

void AMyActor::DoSomething() { /* logic */ } // ✅

✔️ 3. Check for Misspelled Names or Wrong Scopes

Make sure your .cpp definition exactly matches your .h declaration, including class scope.

Wrong:

int32 Counter = 0; // ❌ Not in the AMyActor scope

Fix:

int32 AMyActor::Counter = 0; // ✅ Correct scope

✔️ 4. Don’t Rely on Incomplete Template Definitions Across Files

If you’re using templated code, ensure both declaration and definition are in the same header file — otherwise, the linker won’t be able to find the implementation.


✅ Summary: How to Fix LNK2001 in UE5

CauseFix Example
Static variable declared but not definedDefine it in .cpp: int32 AMyActor::Counter = 0;
Function declared but missing bodyImplement it in your source file
Scope mismatch in definitionMatch exact class/function scope from header
Templates used across modules improperlyInclude full definition in the same header
Was this article helpful to you? Yes No

How can we help?