# Cannot open source file name.generated.hc

**URL:** <https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312>\
**Category:** C++\
**Tags:** error, header, unreal-engine, generated, CPP, question\
**Created:** [December 28, 2017, 8:42pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312 "2017-12-28T20:42:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrZelektronz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrZelektronz](https://forums.unrealengine.com/u/MrZelektronz)\
**Post date:** [December 28, 2017, 8:42pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/1 "2017-12-28T20:42:54Z")

</div>

Hey guys, I have a problem with my UE4 project, every time I want to compile I get an error which says that the generated.h class of every class of mine cannot be opened. And yes I tried this: Rightclick on .uproject and Generate VS project files but nothing changed.

 ![225317-screenshot-49.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/1/d41e9b26c6152ccf7ceac0c54ee7baa7edcc6004.png)

---

<div class="post-metadata">

**Author:** ![Vizgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vizgin](https://forums.unrealengine.com/u/Vizgin)\
**Post date:** [December 28, 2017, 9:04pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/2 "2017-12-28T21:04:42Z")

</div>

Hi,

You need to do a little more than just regenerating VS project files. Close both the Unreal Editor and Visual Studio. Open your project directory and delete all these folders - **.vs** , **Binaries** , **Intermediate** , **Saved** [optional], and also **YourGame.sln** files. Make sure that the **Config** folder is there and that you do **NOT** accidentally delete it!

Next, right click on the **YourGame.urpoject** and select **Generate Visual Studio project files**. Open the .uproject file once it finishes regenerating. The Editor will prompt you with a missing .dll module again and will ask you to rebuild the solution. Click Yes and it will start rebuilding. It should now successfully compile if there are no bugs in your code.

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![MrZelektronz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrZelektronz](https://forums.unrealengine.com/u/MrZelektronz)\
**Post date:** [December 28, 2017, 9:19pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/3 "2017-12-28T21:19:58Z")

</div>

Thank you 😃 It worked ^^ Well, I needed to rebuild it manually because of some minor coding errors but then it worked

---

<div class="post-metadata">

**Author:** ![Vizgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vizgin](https://forums.unrealengine.com/u/Vizgin)\
**Post date:** [December 28, 2017, 9:22pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/4 "2017-12-28T21:22:48Z")

</div>

You’re welcome 🙂 Please consider marking the question as “resolved” to help us better filter unanswered questions. Thanks.

---

<div class="post-metadata">

**Author:** ![MrZelektronz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrZelektronz](https://forums.unrealengine.com/u/MrZelektronz)\
**Post date:** [December 28, 2017, 9:24pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/5 "2017-12-28T21:24:22Z")

</div>

Well but now every time I wanna start the project the editor crashes without any error message

---

<div class="post-metadata">

**Author:** ![Vizgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vizgin](https://forums.unrealengine.com/u/Vizgin)\
**Post date:** [December 28, 2017, 9:26pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/6 "2017-12-28T21:26:44Z")

</div>

It’s probably because of null accessing somewhere in your code. Please refer to my other answer [here](https://answers.unrealengine.com/questions/736215/stops-loading-at-73.html#answer-container-739670) where I provide some guidelines and tips on how to address these types of errors.

---

<div class="post-metadata">

**Author:** ![MrZelektronz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrZelektronz](https://forums.unrealengine.com/u/MrZelektronz)\
**Post date:** [December 28, 2017, 9:46pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/7 "2017-12-28T21:46:26Z")

</div>

Thank you for that advice but this is not the case 😕 There must be another reason for it to crash

---

<div class="post-metadata">

**Author:** ![Vizgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vizgin](https://forums.unrealengine.com/u/Vizgin)\
**Post date:** [December 28, 2017, 10:06pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/8 "2017-12-28T22:06:21Z")

</div>

If you cannot debug please provide more information (preferably with pictures) of the errors you’re getting and post them either here if they’re relevant or as a new question.

---

<div class="post-metadata">

**Author:** ![RosProPlays](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RosProPlays](https://forums.unrealengine.com/u/RosProPlays)\
**Post date:** [September 3, 2018, 2:58pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/9 "2018-09-03T14:58:09Z")

</div>

Hello i ve the same problem, but when i lucked to rebild the projec it says the project cannot be compiled try to rebuild it maually from source. How to do it?

---

<div class="post-metadata">

**Author:** ![TheDreamCatcher](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thedreamcatcher/32/727178_2.png) [@TheDreamCatcher](https://forums.unrealengine.com/u/TheDreamCatcher)\
**Post date:** [September 4, 2018, 4:40am UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/10 "2018-09-04T04:40:59Z")

</div>

This looks more like the 4.20 bug that does not provide the correct includes. just add the full path to `ProjectName/Intermediate/Build/PLATFORM/UE4Editor/Inc/ProjectName` before any generated.h file and you should be good to go

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1c45a3481](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1c45a3481](https://forums.unrealengine.com/u/anonymous_user_1c45a3481)\
**Post date:** [October 27, 2018, 7:19pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/11 "2018-10-27T19:19:54Z")

</div>

Seems like a bug with visual studio,all I did was rightclick-\>Open Document and then it started compiling normally for me.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_931bf5a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_931bf5a4](https://forums.unrealengine.com/u/anonymous_user_931bf5a4)\
**Post date:** [January 14, 2019, 8:58pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/12 "2019-01-14T20:58:45Z")

</div>

This made no difference to my project, and because it’s a nuke-the-site-from-orbit solution, provides no insight as to what the actual problem is.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_3af026a2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3af026a2](https://forums.unrealengine.com/u/anonymous_user_3af026a2)\
**Post date:** [January 24, 2019, 10:34pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/13 "2019-01-24T22:34:36Z")

</div>

Ok now, my project have error when rebuild and doesnt open at all.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_564f6a11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_564f6a11](https://forums.unrealengine.com/u/anonymous_user_564f6a11)\
**Post date:** [June 10, 2019, 5:27pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/14 "2019-06-10T17:27:58Z")

</div>

Please Mark This as the correct solution. I almost skipped this page. Works Like… !

---

<div class="post-metadata">

**Author:** ![GoldenCuda](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GoldenCuda](https://forums.unrealengine.com/u/GoldenCuda)\
**Post date:** [September 12, 2020, 8:19pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/15 "2020-09-12T20:19:11Z")

</div>

This normally happens when you rename a blueprint, or changed its location. Check your c++ referencing the blueprint or its path in the file referencing it. Also note the \_C at the end denotes that its a class which is generated but is not part of the actual name

---

<div class="post-metadata">

**Author:** ![Abcansis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Abcansis](https://forums.unrealengine.com/u/Abcansis)\
**Post date:** [February 12, 2021, 3:18pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/16 "2021-02-12T15:18:54Z")

</div>

Soo…  
What worked for me is:

1. Close engine and generate visual studio files
2. Open the game.sln file with Visual Studio
3. Set on Development editor
4. Debug the project  
The Visual Studio rebuilds the project and then runs the project.  
Afterwards everything works perfectly.

---

<div class="post-metadata">

**Author:** ![Abcansis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Abcansis](https://forums.unrealengine.com/u/Abcansis)\
**Post date:** [February 12, 2021, 3:19pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/17 "2021-02-12T15:19:13Z")

</div>

Soo…  
What worked for me is:

1. Close engine and generate visual studio files
2. Open the game.sln file with Visual Studio
3. Set on Development editor
4. Debug the project  
The Visual Studio rebuilds the project and then runs the project.  
Afterwards everything works perfectly.

---

<div class="post-metadata">

**Author:** ![ImpOfThePerverse](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ImpOfThePerverse](https://forums.unrealengine.com/u/ImpOfThePerverse)\
**Post date:** [February 23, 2021, 4:30pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/18 "2021-02-23T16:30:11Z")

</div>

Not sure if this is related, but I think I figured out what was making this type of error happen for me. ClassA’s header file was including ClassB’s header file so that it could declare a struct member variable of a type declared in ClassB’s header. ClassB’s .cpp file was including ClassA’s header so that it could work with ClassA, and I think it was causing some circular include problems. Luckily ClassA really only needed to store an FVector from ClassB’s struct, so I passed that instead. I got rid of the include in Class A’s header, and it compiled.

---

<div class="post-metadata">

**Author:** ![pawciut](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pawciut/32/476660_2.png) [@pawciut](https://forums.unrealengine.com/u/pawciut)\
**Post date:** [February 8, 2022, 2:07pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/19 "2022-02-08T14:07:15Z")

</div>

For me it was not related to the file specified in the error message but it has to do with the file that was being compiled one line above in Build Output in Visual Studio.

Turned out that I had some left over includes that could not be resolved after separating file into different module. After fixing those includes it compiled without errors.

---

<div class="post-metadata">

**Author:** ![AnastasiiaTrying1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AnastasiiaTrying1](https://forums.unrealengine.com/u/AnastasiiaTrying1)\
**Post date:** [August 10, 2022, 3:06pm UTC](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312/20 "2022-08-10T15:06:35Z")

</div>

Hello, I had same problem.  
I hope this can help somebody.  
It’s important that this problem started when I created new C++ class in UE Editor, and I put it in subfolder X. So in cpp file of my class was string

> #include “X/MyClass.h”

but should be just

> #include “MyClass.h”

so problem was just that

[Next page](https://forums.unrealengine.com/t/cannot-open-source-file-name-generated-hc/413312.md?page=2)
