"Cannot open include file" compiler error with my own created classes (not "generated.h", not plugin)

I’ve had this problem since I started my project in UE5 5.3, but I was able to avoid it by typing “…/” in front of includes that are not in main “Source” folder.

But now, when I have more “complex” folder structure (Source/folder/folder2) I realized that this “…/” approach is not the best option here, especially when I didnt experience such problem in UE4.

So thats how things look in my project:

  1. I dont have “public”"private" folders, header and .cpp files are in the same folder (I’m just more comfortable this way).
  2. I dont have problems with including .generated.h, engine or plugin headers.
  3. Problem occures only with my headers inside my project.

What i’ve tried and it didnt help (and possiblly make it worse):

  1. Remove Intermediate, .vs and Saved folders and then re-generate VS project files via unreal .uproject file.
  2. re-generate VS project files via unreal .uproject file without removing folders.
  3. Add “${SolutionDir}/MyProject/Source” path to “MyPorject->Properties->VC++ Directories → Include Directories”

3rd part is the most insteresting, I didnt found any include path to my solutions dir / project’s “Source” folder dir in default project properties! So I decided to insert new line in Include Directories.

If I try to re-generate VS files via .uproject then it will delete my change in project’s property. (But it’s not a big deal I think, because it’s not working anyway)

What I’m certain about:

  1. Files that I’m trying to include are certainly there
  2. There is no mistake in include path

Compiler error itself:
fatal error C1083: Cannot open include file: ‘Events/EventActors/YAirBomb.h’: No such file or directory

3 Likes

Alright, I have such a curse: if I ask a question anywhere and to anyone, then after ± 5 minutes I find the solution to my question myself. :slight_smile:

Solution:

Inside my “Source” folder I have “MyProjectName” sub-folder, which contains all folders with my custom .h and .cpp files.

So I was able to fix my problem by inserting

PublicIncludePaths.AddRange(new string[] { "MyProjectName" } );

in MyProjectName.Build.cs

3 Likes

But still, I dont remember having this problem in UE4 projects… Or maybe I forgot that I had this problem? :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.