Cannot open source file "generated.h"

I know this is old but:

  1. This solution never worked for me;
  2. I actually managed to understand what is happening on my side.
  • If you find this happening again it could be a dependency issue related to Unreal modules.

  • Try to see in the compiler log the module it’s checking before the line of the error, it should point you to the module lacking the dependency.

  • The ‘.generated.h’ file belongs to the module you have to add (in the build.cs file).

Unreal documentation does a pretty good job for specifying the modules of most classes so you can check there which module you have to add.

Keep in mind that public dependency modules can only be referenced in the ‘public’ folders, meanwhile private dependency modules can only be referenced in the private folder.

4 Likes