I keep having the Cannot open source file "Filename.generated.h" error.

So, I’m pretty new to Unreal Engine and C++. I was following the C++ Tank vs Zombies tutorial on YouTube, but on the 3rd video
I started to run into a problem. In my Gun.h class, I started to get an error on my #include “Gun.generated.h” class. It says: Cannot open source file “Gun.generated.h”.

error.png

I thought it was because of the “class AIceGirl” underneath it, so I commented that out and compiled the project again. But now I’m getting this error and I have no idea what it means.

Here’s the code of the Gun.h class:

  1. check if your ICEDEFENDER_API matches the module name
  2. check if your .cs file has the following lines

  PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;


PublicIncludePaths.Add (Path.Combine (ModuleDirectory, "Public"));
PrivateIncludePaths.Add (Path.Combine (ModuleDirectory, "Private"));

if you use version < 4.18 (? 4.19) use the lines above and uncomment out the lines like



/* PublicIncludePaths.AddRange ...
/* PrivateIncludePaths.AddRange ...


upd: your error lnk1169
check if you connect the .cpp file twice
Check if you connect .cpp in the .h file
this is a common error in C ++ if the .cpp file is connected twice

Intellisense errors (the squiggly red line) aren’t real errors, generally speaking when using Unreal. Intellisense has a terrible time parsing UE code (which is why so many people use Visual Assist instead).

Your build is failing because “UIceGirlStatics::FindLookAtAngel2D” is apparently defined twice.