# LNK2001 error with static class

**URL:** <https://forums.unrealengine.com/t/lnk2001-error-with-static-class/2688556>\
**Category:** Programming & Scripting\
**Tags:** error, unreal-engine, Visual-Studio, CPP\
**Created:** [December 30, 2025, 11:55am UTC](https://forums.unrealengine.com/t/lnk2001-error-with-static-class/2688556 "2025-12-30T11:55:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KingmouseFR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kingmousefr/32/1138667_2.png) [@KingmouseFR](https://forums.unrealengine.com/u/KingmouseFR)\
**Post date:** [December 30, 2025, 11:55am UTC](https://forums.unrealengine.com/t/lnk2001-error-with-static-class/2688556/1 "2025-12-30T11:55:23Z")

</div>

Hello everyone 😉

Here’s a quick solution to the problem mentioned in the title.

I encountered this error:

```auto
Example.cpp.obj : error LNK2001: unresolved external symbol "private: static unsigned short AExample::MyNumber"

```

If you’re wondering why, it’s because I declared the static variable in the header file, but not in the .cpp file. The compiler doesn’t **allocate** the static variable **automatically** , so it returns an error. We must allocate it:

Example.h:

```auto
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Example.generated.h"

UCLASS()
class EXAMPLE_API AExample : public AActor
{
	GENERATED_BODY()

private:
// However, the variable has not been declared. We must do this in the .cpp file.
static uint16 MyNumber;

}

```

Example.cpp:

```auto
#include "Example/Example.h"

// Allocate here with a default value 
uint16 AExample::MyNumber = 0;

```

The problem will be resolved after that.

As an alternative, it is not recommended to do that in Unreal Engine C++, but here’s a hint:

```auto
// Declare with a inline
inline static uint16 MyNumber;

```

But as already said, it is **not** recomanded to do that, because it’s more power consumer than just declare live the precedent example and you need the `cpp 17`.

I hope that help you!  
If you have some hint or I made mistakes, write below!!!
