Installed 4.26, now no code will compile

I’ve been trying to solve this for months now and I don’t have any choice but to restart my entire project in Unity, salvaging what little code I could. Ever since I installed 4.26 none of my projects work. No previous or current version will compile any C++ code within any folders. Always gives me this error code;

C:\Project Files\UE4\ExampleProj\Source\ExampleProj\Actors\ExamplePawn.cpp(4): fatal error C1083: Cannot open include file: ‘Actors/ExamplePawn.h’: No such file or directory

Code compiles perfectly fine when not inside any sub-folders. For example ExampleProj\ExamplePawn.cpp would compile fine, but ExampleProj\Actors\ExamplePawn.cpp will not.

I’ve uninstalled Windows and that didn’t work. I’ve uninstalled VS 2019 and that didn’t work. I uninstalled UE4 and that didn’t work. I have no other ideas than buy a new PC and hope, or just stop using UE4.

  1. What version are you upgrading from?

  2. Does auto complete when trying to include a file give any hints as to what is missing? You could try including with or without the ExampleProj as a prefix. So try both #include "ExampleProj/Actors/ExamplePawn.h" and #include "Actors/ExamplePawn.h"

  3. In your Build.cs, you can try setting bLegacyPublicIncludePaths = true to see if that helps. I would try #2 both with and without this part, as this build option can affect which paths will compile or not.

After resetting Windows the error only happened on 4.26, before it was on any version. Setting bLegacyPublicIncludePaths = true fixed the issue. Is it bad practice to include code outside Public / Private paths?

Oh okay. Thanks! I tried extending the include path first (as that’s the line the error sites, obviously) but it didn’t change anything. Tried ExampleProj/Actors/… , with the full folder path, and with various other configurations. None helped.

When bLegacyPublicIncludePaths = false, UE omits subfolders from public include paths to reduce compiler command line length. The main impact that I have seen from it is that, when false, you need to specify the path more explicitly, which is why I suggested trying #include "ExampleProj/... before changing this.

With the setting turned on, you may run into issues with the compiler command line being too long (which was my issue and how I found out about this), but it defaulted to true in 4.24 and previous versions, so I think it is mostly an option for you to decide, not better or worse practice one way or the other.