Unreal Engine 4 giving "failed to automatically hot reload the module" error whenever creating any C++ classes in any projects

This error won’t shows If I create the C++ Class(C++ Actor or other objects) in the default path “ProjectName\Source\ProjectName”

It only shows when I try to create the C++ Class Inside any sub-folder of that Default Path like “ProjectName\Source\ProjectName\SubFolder”

Everything was working fine but then I tried to update to VS2022 after uninstalling VS2019
but VS2022 didn’t installed so I Installed back VS2019 again and then this error started showing.
I re-installed both Unreal Engine 4 and VS2019 but the error is still there
By the way I’m using UE4.27.1 because my pc can’t run UE5.

Here is the Unreal’s Output Log

And Here is the text version of that Output Log after creating the Class

LogEditorClassViewer: Warning: Class /Engine/Tutorial/InWorldBlueprintEditing/TutorialAssets/IWBE_Blutility.IWBE_Blutility_C has parent /Script/Blutility.PlacedEditorUtilityBase, but this parent is not found. The Class will not be shown in ClassViewer.
LogSlate: Took 0.000315 seconds to synchronously load lazily loaded font ‘…/…/…/Engine/Content/Slate/Fonts/Roboto-BoldCondensed.ttf’ (158K)
Running D:/Installed Software/Epic Games/UE_4.27/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project=“E:/Documents/3D/Unreal Engine Project/TestProject/TestProject.uproject” -game -rocket -progress
Discovering modules, targets and source code for project…
Binding IntelliSense data…
Binding IntelliSense data… 100%
Writing project files…
Writing project files… 67%
Writing project files… 100%
Candidate modules for hot reload:
TestProject
Launching UnrealBuildTool… [D:/Installed Software/Epic Games/UE_4.27/Engine/Binaries/DotNET/UnrealBuildTool.exe -ModuleWithSuffix=TestProject,7875 TestProjectEditor Win64 Development -Project=“E:/Documents/3D/Unreal Engine Project/TestProject/TestProject.uproject” “E:/Documents/3D/Unreal Engine Project/TestProject/TestProject.uproject” -IgnoreJunk]
CompilerResultsLog: New page: Compilation - Oct 20, 2023, 7:15:20 PM
CompilerResultsLog: Creating makefile for TestProjectEditor (no existing makefile)
CompilerResultsLog: Parsing headers for TestProjectEditor
CompilerResultsLog: Running UnrealHeaderTool “E:\Documents\3D\Unreal Engine Project\TestProject\TestProject.uproject” “E:\Documents\3D\Unreal Engine Project\TestProject\Intermediate\Build\Win64\TestProjectEditor\Development\TestProjectEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -abslog=“C
:\Users\sksaf\AppData\Local\UnrealBuildTool\Log_UHT.txt” -installed
CompilerResultsLog: LogInit: Display: Loading text-based GConfig…
CompilerResultsLog: Reflection code generated for TestProjectEditor in 30.1579494 seconds
CompilerResultsLog: Building TestProjectEditor…
CompilerResultsLog: Using Visual Studio 2019 14.29.30152 toolchain (D:\Installed Software\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133) and Windows 10.0.17763.0 SDK (C:\Program Files (x86)\Windows Kits\10).
CompilerResultsLog: Building 5 actions with 8 processes…
CompilerResultsLog: [1/5] TestActor.cpp
CompilerResultsLog: E:\Documents\3D\Unreal Engine Project\TestProject\Source\TestProject\Folder\TestActor.cpp(4): fatal error C1083: Cannot open include file: ‘Folder/TestActor.h’: No such file or directory
CompilerResultsLog: [2/5] TestActor.gen.cpp
LogMainFrame: MainFrame: Module compiling took 71.330 seconds
Warning: HotReload failed, recompile failed
Warning: RebindPackages failed because compilation failed.
LogSlate: Window ‘Message’ being destroyed
Message dialog closed, result: Yes, title: Message, text: Successfully added class ‘TestActor’, however you must recompile the ‘TestProject’ module before it will appear in the Content Browser. Failed to automatically hot reload the ‘TestProject’ module.
Would you like to open the Output Log to see more details?
LogSlate: Window ‘Add C++ Class’ being destroyed

And I tried building the project from inside VS 2019
but then this error is showing in VS 2019

And Here is the text version of that VS2019 Error

Code: C1083
Description: Cannot open include file: ‘Folder/TestActor.h’ No such file or directory
Project: TestProject
File: TestActor.cpp

Code: MSB3073
Description: The command ““D:\Installed Software\Epic Games\UE_4.27\Engine\Build\BatchFiles\Build.bat” TestProjectEditor Win64 Development -Project=“E:\Documents\3D\Unreal Engine Project\TestProject\TestProject.uproject” -WaitMutex -FromMsBuild” exited with code 6.
Project: TestProject
File: Microsoft.MakeFile.Targets

I would really appreciate any solution for this, I have no idea what’s going on

I Found the answer, I’m leaving it here if anyone else having the same problem in future

Unreal’s class generation doesn’t properly handle subdirectories so you will need to fix up the code yourself.

The code is doing

#include "Folder/TestActor.h"

That code is trying to find a file called TestActor.h in a sub directory which is incorrect as they are in the same directory. i.e it would be correct for the following

Source/
├─ TestProject/
│  ├─ Folder/
│  │  ├─ TestActor.cpp
│  │  ├─ Folder/
│  │  │  ├─ TestActor.h
  • So simply remove “Folder/” in the cpp file and then manually building the project from Visual Studio

  • The auto generation expects you to use the public/private folder structure since that’s the UE convention. There’s no way that I know of to fix it, other than start using it yourself. When you go to create a new class in the editor you will see that on the window where you type in the path you want, there’s buttons that say public/private… click the public button and it will default to putting the header in the Public section and the .cpp in the Private section

I really want to thank these peoples in below for quick reply and especially since nobody answered in Unreal’s Own Community

  • GameDevTv’s Daniel Marshall

  • battledrake, shadow355e3b and zaelus from Discord server of DruidMechanics Game
    Developer Community

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