VS cannot find generated.h files

  1. UE 4.20 clean fresh installation.
  2. Created New project - C++ Base Code
  3. In UE Editor double click on C++ Classes \ MyProject \ MyProjectBameModeBase (generated during the project creation)
  4. VS 2017 automatically opened
  5. There’s an error: cannot open file MyProjectGameModeBase.generated.h

Imgur

The exact same error every time I try to add new C++ class via UE Editor (for example an Actor class).

Any ideas?

Thanks.

Edit: I tried the trick with deleting files (.vs, Binaries, Intermediate, Saved, *.snl) and re-generating VS project file, but it didn’t help.

Having the same issue.

It’s clearly a bug introduced in 4.20. I don’t understand how this build was approved by QA with such a bug.

Anyway, I found out what is happening and how to solve it manually. You will have to do this everytime after you generate the project files (annoying but currently is the only way).

The problem is that the UBT is not adding the intermediate include directories to the NMakeIncludeSearchPath property in the visual studio project when it generates the project files.

Workaround:

  1. Open the project solution
  2. Inside Visual Studio go to Project → Properties
  3. In configuration select “All Configurations”
  4. In the Configuration Properties tree select NMake
  5. Click the dropdown for the “Include Search Path” item and select “Edit…”
  6. Click the “New Line” button at the top right of the window and add this path “…\Build\Win64\UE4Editor\Inc\YourModuleName” without the quotes.
  7. Repeat step 6 for each c++ module in your project

Let me know if this helps you until Epic makes a hotfix for this.

1 Like

That did not work for me…

Thanks for the answer, . It helped me to solve the issue with the include, but I’m still getting other errors Imgur: The magic of the Internet

I guess I’ll wait for the fix.

Sorry, my bad, I fixed the path.

Vote!

Thank you so much for figuring this out. I was excited to use IntelliSense and it was extremely frustrating that it wasn’t working correctly at all. I appreciate you taking the time to make the issue and spread the solution around; hopefully Epic sees this SOON!

Edit: Also, you accidentally put a double backslash in the path before YourModuleName.

Fixed. Thank you!

Thank you so much for this answer. However, I’m still a bit confused by step 6 in the answer and I have a couple of stupid questions:

What exactly should I replace the YourModuleName with? Is it every C++ header file or the actual C++ files? Sorry I’m new at this.

Thanks in advance!

By default when you create a C++ project in UE4 one gameplay module is automatically created with the same name as your project. So you can put your project’s name there.

In bigger projects this may be different as you can add multiple gameplay modules and even editor modules.

I recommend you read the gameplay modules documentation. It’s fundamental to understand them while programming with C++ for UE4 and you may find useful to configure multiple modules when working on a medium to big sized project

Hope that gets you up and running.

Can’t see how this will help because mine is failing on generated.h files that are part of UE4 (and genuinely do not exist).

This is still a bug (at least on Linux) for commit hash 811c1ce579564fa92ecc22d9b70cbe9c8a8e4b9a (tested on CLion and Qt Creator)

Still have this problem and adding

$(ProjectDir)…\Build\Win64\UE4Editor\Inc\MyModuleName

didn’t help. Seems that something internal bypassed the include search path.

Because I still had this issue today with the newest version I would like to add. Don’t forget to save the .sln. Easied way to do this is just closing VS after adding the path and it will ask you to save the file.
Open VS again and everything should be fine.

Thanks for the fix btw.