Cannot open source file name.generated.hc

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.

3 Likes

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 :slight_smile:

19 Likes

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

1 Like

It’s probably because of null accessing somewhere in your code. Please refer to my other answer here where I provide some guidelines and tips on how to address these types of errors.

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

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

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

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.

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?

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

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

1 Like

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.

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

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

1 Like

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

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.
1 Like

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.
1 Like

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.

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.

1 Like

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

2 Likes