# Cannot include .generated.h but it exists

**URL:** <https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059>\
**Category:** C++\
**Tags:** error, error-compile, unreal-engine, generated, question, CPP\
**Created:** [January 8, 2018, 4:56pm UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059 "2018-01-08T16:56:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjaml](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@benjaml](https://forums.unrealengine.com/u/benjaml)\
**Post date:** [January 8, 2018, 4:56pm UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059/1 "2018-01-08T16:56:02Z")

</div>

Hello,

I’m currently trying to add a custom module to my game, but I got a class in this new module that fails to compile because it cannot include it’s generated.h file

Here is the header of the class :

```
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameStateBase.h"
#include <map>
#include "Kea/Characters/Components/HealthComponent.h"
#include "EntityManager.generated.h"

/**
 * 
 */
UCLASS()
class SKILLCASTERMODULE_API AEntityManager : public AGameStateBase
{
	GENERATED_BODY()

public:
	AEntityManager();
	std::map<int, AActor*> EntityMap;	
	void AddEntity(int, AActor*);
};

```

This gives me this error :

```
Cannot open include file: 'EntityManager.generated.h': No such file or directory
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_49a519741](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_49a519741](https://forums.unrealengine.com/u/anonymous_user_49a519741)\
**Post date:** [January 8, 2018, 5:09pm UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059/2 "2018-01-08T17:09:56Z")

</div>

2nd time writing this because the web server boned me…again.

Try rebuilding everything from scratch. If you don’t know how, here it is:

1. Exit the editor and back up the project (just in case)
2. Delete these directories from your project folder tree: .vs, Binaries, Build, Debug, Intermediate, Saved
3. Re-generate project files (right-click your uproject file and choose “Generate Project Files”)
4. Open the Visual Studio solution (YourProject.sln)
5. Build your project for “Development Editor” (should be set already)

If that doesn’t do it then post your CPP file too I guess.

---

<div class="post-metadata">

**Author:** ![benjaml](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@benjaml](https://forums.unrealengine.com/u/benjaml)\
**Post date:** [January 9, 2018, 9:22am UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059/3 "2018-01-09T09:22:00Z")

</div>

It does not solve the problem.

Here is my cpp file :

```
#include "EntityManager.h"
#include "SkillCasterModule.h"
#include "Kea/CLRService.h"	

AEntityManager::AEntityManager()
{
	PrimaryActorTick.bCanEverTick = true;
	EntityMap = std::map<int, AActor*>();
}

void AEntityManager::AddEntity(int id, AActor* actor)
{
	EntityMap.insert(std::pair<int, AActor *>(id, actor));
	CLRService* service = CLRService::GetService();
	if (service)
	{
		HINSTANCE dllHandle = service->GetDllHandle();
		if (dllHandle)
		{
			IntParameterFunc func = (IntParameterFunc)GetProcAddress(dllHandle, "AddCharacter");
			if (func)
			{
				func(id);
			}
		}
	}
}
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_49a519741](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_49a519741](https://forums.unrealengine.com/u/anonymous_user_49a519741)\
**Post date:** [January 9, 2018, 10:29am UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059/4 "2018-01-09T10:29:28Z")

</div>

Responding to below…

EntityManager.cpp is in the solution, getting built? Is it building EntityManager.gen.cpp? (It will only build it the first time, FYI.) Is there another error before the missing file error?

Does an unaltered C++ template project build OK?

If so, it must be how you’re doing this custom module. The file isn’t getting generated so something must be wrong there. You’ll need to provide more details about the module and how you project is set up.

---

<div class="post-metadata">

**Author:** ![benjaml](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@benjaml](https://forums.unrealengine.com/u/benjaml)\
**Post date:** [January 9, 2018, 10:35am UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059/5 "2018-01-09T10:35:27Z")

</div>

I’ve succeed to correct this by adding the class through Unreal editor

---

<div class="post-metadata">

**Author:** ![Fidilip](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fidilip](https://forums.unrealengine.com/u/Fidilip)\
**Post date:** [April 4, 2023, 3:02pm UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059/6 "2023-04-04T15:02:05Z")

</div>

I’ve had the same problem recently.  
My problem was including the header file in a different module (let’s call it `ForeignModule`) with path like this:

```auto
#include "MyModule/Public/MyClass.h"

```

The correct solution was to include:

```auto
#include "MyClass.h"

```

And add `"MyModule"` to the `ForeignModule.Build.cs` file.

---

<div class="post-metadata">

**Author:** ![Mifthbeat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mifthbeat/32/919874_2.png) [@Mifthbeat](https://forums.unrealengine.com/u/Mifthbeat)\
**Post date:** [February 24, 2024, 9:08pm UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059/7 "2024-02-24T21:08:00Z")

</div>

I had exactly the same error. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![tancen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tancen](https://forums.unrealengine.com/u/tancen)\
**Post date:** [February 13, 2025, 9:21am UTC](https://forums.unrealengine.com/t/cannot-include-generated-h-but-it-exists/414059/8 "2025-02-13T09:21:38Z")

</div>

I forgot to add that module name to my project’s .Build.cs file
