# Trouble adding Blueprint HUD to C++ Project

**URL:** <https://forums.unrealengine.com/t/trouble-adding-blueprint-hud-to-c-project/294138>\
**Category:** Blueprint\
**Tags:** unreal-engine, CPP, Blueprint, question\
**Created:** [September 20, 2014, 3:46am UTC](https://forums.unrealengine.com/t/trouble-adding-blueprint-hud-to-c-project/294138 "2014-09-20T03:46:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e0ecb897](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e0ecb897](https://forums.unrealengine.com/u/anonymous_user_e0ecb897)\
**Post date:** [September 20, 2014, 3:46am UTC](https://forums.unrealengine.com/t/trouble-adding-blueprint-hud-to-c-project/294138/1 "2014-09-20T03:46:06Z")

</div>

Using 4.4.3

Pretty basic question:  
I am using the side-scroller c++ template and wanted to add a blueprint created HUD.

I created a basic blueprint of parent type HUD. I then added the following code to my GameMode.cpp to call the blueprint. I based it off the pre-existing code that sets the default pawn class to the MyCharacter blueprint

```
static ConstructorHelpers::FClassFinder <AHUD> HUD_Cursor(TEXT("/Game/Blueprints/HUD_Cursor"));
HUDClass = (UClass*)HUD_Cursor.Class;

```

However I receive the following compile errors.

* * *

```
Error	4	error MSB3073: The command ""G:\Program Files\Unreal Engine\4.4\Engine\Build\BatchFiles\Build.bat" *****Win64 DebugGame "G:\Users\***** \Documents\Unreal Projects\ *****\*****.uproject" -rocket" exited with code -1.	G:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38	5	*****

Error	2	error C3861: 'StaticClass': identifier not found	G:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h	142	1	*****

Error	1	error C2027: use of undefined type 'AHUD'	G:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h	142	1	*****

Error	3	error : Failed to produce item: G:\Users\ *****\Documents\Unreal Projects\***** \Binaries\Win64\UE4Editor- *****-Win64-DebugGame.pdb	G:\Users\***** \Documents\Unreal Projects\ *****\Intermediate\ProjectFiles\ERROR	*****

```

* * *

(\*\*\*\*\* = censored)

Commenting out the code causes the errors to disappear. I searched around and can’t seem to find a solution. The Blueprint works perfectly fine in the side-scroller blueprint template as all i need to do is set it as the default.  
Not quite sure what’s causing this to fail when using c++. Any ideas?

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [September 20, 2014, 7:57am UTC](https://forums.unrealengine.com/t/trouble-adding-blueprint-hud-to-c-project/294138/2 "2014-09-20T07:57:09Z")

</div>

#Wiki Tutorial Solution

I have a whole tutorial on doing this process for a player controller, just switch out my code sample for doing the HUD instead!

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

#Analysis

Use ConstructorHelpers::FObjectFinder instead of class finder, and just copy the reference of your HUD BP directly (right click-\>copy reference)

Rama

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e0ecb897](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e0ecb897](https://forums.unrealengine.com/u/anonymous_user_e0ecb897)\
**Post date:** [September 20, 2014, 7:47pm UTC](https://forums.unrealengine.com/t/trouble-adding-blueprint-hud-to-c-project/294138/3 "2014-09-20T19:47:10Z")

</div>

Hello Rama,  
I tried to follow your tutorial but it did not get me anywhere.  
I tried the following:

```
	static ConstructorHelpers::FObjectFinder <UBlueprint> HUD_Cursor(TEXT("Blueprint'/Game/Blueprints/HUD_Cursor.HUD_Cursor'"));
	if (HUD_Cursor.Object != NULL)
	{
		HUDClass = (UClass*)HUD_Cursor.Object->GeneratedClass;
	}

```

I also tried using AHUD as well but to no sucess. The only benefit I got from the tutorial was it pointed out I was using the incorrect blueprint reference format.

Here are the errors I receive when I try to compile the above snippet:

```
Error	4	error MSB3073: The command ""G:\Program Files\Unreal Engine\4.4\Engine\Build\BatchFiles\Build.bat" ****Editor Win64 DebugGame "G:\Users\**** \Documents\Unreal Projects\********.uproject" -rocket" exited with code -1.	G:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38	5	****

Error	2	error C2227: left of '->GeneratedClass' must point to class/struct/union/generic type	G:\Users\ ****\Documents\Unreal Projects\**** \Source\ ****\Private\**** GameMode.cpp	25	1	****

Error	1	error C2027: use of undefined type 'UBlueprint'	
G:\Users\ **** \Documents\Unreal 
Projects\ ****\Source\**** \Private\ ****GameMode.cpp	25	1	****

Error	3	error : Failed to produce item: G:\Users\ ****\Documents\Unreal Projects\**** \Binaries\Win64\UE4Editor- ****-Win64-DebugGame.dll	G:\Users\**** \Documents\Unreal Projects\ ****\Intermediate\ProjectFiles\ERROR	****

```

Any thoughts on what I am doing incorrectly?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e0ecb897](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e0ecb897](https://forums.unrealengine.com/u/anonymous_user_e0ecb897)\
**Post date:** [September 22, 2014, 1:39am UTC](https://forums.unrealengine.com/t/trouble-adding-blueprint-hud-to-c-project/294138/4 "2014-09-22T01:39:01Z")

</div>

Found the answer and just as I guessed, it was something very basic.  
I needed to simply add the following to my GameMode.cpp

```
#include "GameFramework/HUD.h"

```

However since I wanted to include a C++ class with my blueprint I simply created the class which included GameFramework/HUD.h and then called that in my GameMode.cpp.

Been a while since I used C++ and forgot that #includes can be nested, which is why the default for the side-scroller c++ template has “#include “GameFramework/Character.h”” in the Character.h but not in the GameMode.cpp. This gave me the false assumption that there was some inherent behavior that covered the include for default character, but turned out I just wasn’t smart enough!
