# Compiler Error (Linking Error)? Unresolved External Symbol

**URL:** <https://forums.unrealengine.com/t/compiler-error-linking-error-unresolved-external-symbol/15581>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 20, 2014, 11:37am UTC](https://forums.unrealengine.com/t/compiler-error-linking-error-unresolved-external-symbol/15581 "2014-11-20T11:37:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2bda08f8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2bda08f8](https://forums.unrealengine.com/u/anonymous_user_2bda08f8)\
**Post date:** [November 20, 2014, 11:37am UTC](https://forums.unrealengine.com/t/compiler-error-linking-error-unresolved-external-symbol/15581/1 "2014-11-20T11:37:30Z")

</div>

Hey guys,

can someone please explains a way to fix this compiler error? I’ve tried to look at some sources but I don’t seems to get the answer.  
Is the problem lies in missing headers?

What does linking error means?

 ![61f54c9fa9220ded00da505a92d733dfda784e1b.jpeg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/f/61f54c9fa9220ded00da505a92d733dfda784e1b.jpeg)

I am very new at C++ and programming. Can I please get some help with detailed step?

I tried to follow FPS game mode tutorial from [A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums](https://wiki.unrealengine.com/First_Person_Shooter_C%2B%2B_Tutorial)

I thought it would be a good start. I’m pretty sure I followed every single step as mentioned but in the end I got stuck in the first compiling step.

Here is the code I changed according to the tutorial

```auto

#include "Shattered_Code.h"
#include "Shattered_CodeGameMode.h"

AShattered_CodeGameMode::AShattered_CodeGameMode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

	Super::BeginPlay();
	StartMatch();
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
	}
}

```

```auto

#pragma once

#include "GameFramework/GameMode.h"
#include "FPSGame_Mode.generated.h"

/**
 * 
 */
UCLASS()
class SHATTERED_CODE_API AFPSGame_Mode : public AGameMode
{
	GENERATED_UCLASS_BODY()

	virtual void StartPlay() override; //at Start// 
	
	
};

```

Also I want to know where Start Play is derived from. Is it necessary to a certain header for StartPlay to work?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_fc4c82b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fc4c82b6](https://forums.unrealengine.com/u/anonymous_user_fc4c82b6)\
**Post date:** [November 20, 2014, 12:13pm UTC](https://forums.unrealengine.com/t/compiler-error-linking-error-unresolved-external-symbol/15581/2 "2014-11-20T12:13:04Z")

</div>

Super::BeginPlay() is a method declaration, you have to define it in the .cpp:

AShattered\_CodeGameMode::StartPlay()  
{  
Super::StartPlay();  
}

Instead you call it in the Constructor via Super::BeginPlay() , I guess you got a mistake in the name there ? (BeginPlay vs StartPlay?)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2bda08f8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2bda08f8](https://forums.unrealengine.com/u/anonymous_user_2bda08f8)\
**Post date:** [November 20, 2014, 12:25pm UTC](https://forums.unrealengine.com/t/compiler-error-linking-error-unresolved-external-symbol/15581/3 "2014-11-20T12:25:42Z")

</div>

Wups, Thanks for that. I place the method in the obvious wrong place. I will try to fix it and see how it goes

Edit:

I added the function below the constructor

but I get this Error

Error 1 error C2509: ‘BeginPlay’ : member function not declared in ‘AShattered\_CodeGameMode’ D:\Unreal\_Projects\Shattered\_Prototype\Shattered\_Code\Source\Shattered\_Code\Shattered\_CodeGameMode.cpp 16 1 Shattered\_Code

The code is as follow

```auto

// Fill out your copyright notice in the Description page of Project Settings.

#include "Shattered_Code.h"
#include "Shattered_CodeGameMode.h"

AShattered_CodeGameMode::AShattered_CodeGameMode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

	
}

void AShattered_CodeGameMode::BeginPlay()
{
	Super::BeginPlay();

	StartMatch();

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
	}
}

```

How to declare a function??

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_fc4c82b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fc4c82b6](https://forums.unrealengine.com/u/anonymous_user_fc4c82b6)\
**Post date:** [November 20, 2014, 1:00pm UTC](https://forums.unrealengine.com/t/compiler-error-linking-error-unresolved-external-symbol/15581/4 "2014-11-20T13:00:08Z")

</div>

You have to declare a function in the .h file (the 2nd code snippet in your first post), like this:

```auto

virtual void StartPlay() override; //at Start//

```

You declared STARTPLAY though, and if you write BeginPlay instead, you can use it in the .cpp file, like you just did:

.cpp

```auto

// Fill out your copyright notice in the Description page of Project Settings.

#include "Shattered_Code.h"
#include "Shattered_CodeGameMode.h"

AShattered_CodeGameMode::AShattered_CodeGameMode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

	
}

void AShattered_CodeGameMode::BeginPlay()
{
	Super::BeginPlay();

	StartMatch();

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
	}
}

```

```auto

#pragma once

#include "GameFramework/GameMode.h"
#include "FPSGame_Mode.generated.h"

/**
 * 
 */
UCLASS()
class SHATTERED_CODE_API AFPSGame_Mode : public AGameMode
{
	GENERATED_UCLASS_BODY()

	virtual void BeginPlay() override; //at Start// 
	
	
};

```

I didn’t test it, but that should work 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2bda08f8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2bda08f8](https://forums.unrealengine.com/u/anonymous_user_2bda08f8)\
**Post date:** [November 20, 2014, 2:47pm UTC](https://forums.unrealengine.com/t/compiler-error-linking-error-unresolved-external-symbol/15581/5 "2014-11-20T14:47:02Z")

</div>

Hmm ☹ It still gives me unresolved external symbol ☹

Sry to confuse you but I made a mistake on the placement.

Ignore the Shattered\_Code . I need to print a simple text from FPSGame\_Mode Class

This is the .cpp file

```auto

// Fill out your copyright notice in the Description page of Project Settings.

#include "Shattered_Code.h"
#include "FPSGame_Mode.h"
#include "Engine.h"  

AFPSGame_Mode::AFPSGame_Mode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

}

void AFPSGame_Mode::StartPlay()
{
	Super::StartPlay();

	StartMatch();

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
	}
}

```

and this is the header

```auto

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/GameMode.h"
#include "FPSGame_Mode.generated.h"

/**
 * 
 */
UCLASS()
class SHATTERED_CODE_API AFPSGame_Mode : public AGameMode
{
	GENERATED_UCLASS_BODY()

	virtual void StartPlay() override; //at Start// 
	
	
};

```

I think this should be fine, and a simple task. however I still get this error ☹

```auto

Error	1	error LNK2001: unresolved external symbol "public: virtual void __cdecl AShattered_CodeGameMode::StartPlay(void)" (?StartPlay@AShattered_CodeGameMode@@UEAAXXZ)	D:\Unreal_Projects\Shattered_Prototype\Shattered_Code\Intermediate\ProjectFiles\Shattered_CodeGameMode.cpp.obj	Shattered_Code

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2bda08f8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2bda08f8](https://forums.unrealengine.com/u/anonymous_user_2bda08f8)\
**Post date:** [November 20, 2014, 3:05pm UTC](https://forums.unrealengine.com/t/compiler-error-linking-error-unresolved-external-symbol/15581/6 "2014-11-20T15:05:24Z")

</div>

Wups… I declared another StartPlay() in another header file… It’s working now. Thank you very much! 🙂
