Add new empty C++ Class Compiling failed

Hello all
I am new to the Unreal Engine and hope you can help me with my problem.
In my projects I need to add an empty C++ class to be able to stream my project through a provider.

Every time I try to create an empty C++ class I get this error message. And it says Compiling Failed in the bottom right corner.

Message dialog closed, result: Yes, title: Message, text: Successfully added class ‘TestClass’, however you must recompile the ‘Test2’ module before it will appear in the Content Browser. Failed to compile newly created game module.
Would you like to open the Output Log to see more details?

In the output log you can see this information:

Running C:/Program Files/Epic Games/UE_4.26/Engine/Binaries/DotNET/UnrealBuildTool.exe  -projectfiles -project="C:/Users/Etienne Hüsler/Documents/Unreal Projects/Test2/Test2.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... 100%
LogHotReload: Recompiling module Test2...
LogVSAccessor: Warning: Couldn't access Visual Studio
Candidate modules for hot reload:
  Test2
Launching UnrealBuildTool... [C:/Program Files/Epic Games/UE_4.26/Engine/Binaries/DotNET/UnrealBuildTool.exe  -ModuleWithSuffix=Test2,8667 Test2Editor Win64 Development -Project="C:/Users/Etienne Hüsler/Documents/Unreal Projects/Test2/Test2.uproject" "C:/Users/Etienne Hüsler/Documents/Unreal Projects/Test2/Test2.uproject"  -IgnoreJunk]
Creating makefile for Test2Editor (no existing makefile)
Parsing headers for Test2Editor
  Running UnrealHeaderTool "C:\Users\Etienne H?sler\Documents\Unreal Projects\Test2\Test2.uproject" "C:\Users\Etienne H?sler\Documents\Unreal Projects\Test2\Intermediate\Build\Win64\Test2Editor\Development\Test2Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="C:\Users\Etienne H?sler\App
Data\Local\UnrealBuildTool\Log_UHT.txt" -installed
Reflection code generated for Test2Editor in 3.1846846 seconds
Building Test2Editor...
Using Visual Studio 2019 14.29.30037 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 7 actions with 20 processes...
  [1/7] Default.rc2
  [2/7] SharedPCH.Engine.ShadowErrors.cpp
  c1xx: fatal error C1083: Datei (Compilerzwischenstufe) kann nicht ge?ffnet werden: "C:\Users\Etienne HǬsler\Documents\Unreal Projects\Test2\Intermediate\Build\Win64\Test2Editor\Development\Engine\SharedPCH.Engine.ShadowErrors.h.pch": No such file or directory
CompilerResultsLog: New page: Compilation - 15.06.2021, 17:04:32
CompilerResultsLog: Creating makefile for Test2Editor (no existing makefile)
CompilerResultsLog: Parsing headers for Test2Editor
CompilerResultsLog:   Running UnrealHeaderTool "C:\Users\Etienne H?sler\Documents\Unreal Projects\Test2\Test2.uproject" "C:\Users\Etienne H?sler\Documents\Unreal Projects\Test2\Intermediate\Build\Win64\Test2Editor\Development\Test2Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="C:\User
s\Etienne H?sler\AppData\Local\UnrealBuildTool\Log_UHT.txt" -installed
CompilerResultsLog: Reflection code generated for Test2Editor in 3.1846846 seconds
CompilerResultsLog: Building Test2Editor...
CompilerResultsLog: Using Visual Studio 2019 14.29.30037 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
CompilerResultsLog: Building 7 actions with 20 processes...
CompilerResultsLog:   [1/7] Default.rc2
CompilerResultsLog:   [2/7] SharedPCH.Engine.ShadowErrors.cpp
CompilerResultsLog:   c1xx: fatal error C1083: File (compiler intermediate) can not be opened: "C:\Users\Etienne HǬsler\Documents\Unreal Projects\Test2\Intermediate\Build\Win64\Test2Editor\Development\Engine\SharedPCH.Engine.ShadowErrors.h.pch": No such file or directory
LogMainFrame: MainFrame: Module compiling took 5.450 seconds
LogSlate: Window 'Message' being destroyed
Message dialog closed, result: Yes, title: Message, text: Successfully added class 'TestClass', however you must recompile the 'Test2' module before it will appear in the Content Browser. Failed to compile newly created game module.
Would you like to open the Output Log to see more details?
LogSlate: Window 'Add C++ Class' being destroyed

The file that can not be opened is present in this directory but has a different extension: (SharedPCH.Engine.ShadowErrors.h.pch.response)

I have searched for several hours for a solution here in Answerhub but none of these solutions worked.

Thanks for help to solve the problem.

Have you tried building in visual
studio?

This is volatile solution. When he will try to create new c++ from wizard it will happen again.

Generally if you are creating additional folders in C++ to organize your coding or as public private, Unreal creates classes with relative path like #include "[YourFolderName]/[YourClass].h" and this creates confusion in compiler and UBT.

To solve this add below code to your [ProjectName].Build.cs

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

You will no longer have error while using wizard at the editor.
Additionally you can organize your cpp codes easily such below :

341663-uytmk21fw2.png

3 Likes

are you using any custom folder structure in your cpp classes Public/Private included ?

Have you tried building in visual studio?

Open the ProjectName.sln file in your project folder with visual studio and then press the F5 button or the green play button, this will rebuild all C++ files and launch the editor.

Also refer to the Error List and Output windows in Visual Studio if your build fails and the editor does not start up.

Edit: I also noticed this weird character in the path of the file: Ǭ
Can you move your project folder to a folder like C:\UnrealProjects and try to build again?

Thanks for the solution! This used to drive me crazy every time.

So to clarify (because this is a historic post and the same thing happened to me today): This happens not because it’s an empty class, but because you didn’t click on “Public” or “Private” so the path on the include at the top of the CPP file doesn’t resolve properly with default settings?

I fixed mine by changing it to ‘./headerfilename.h’ because they’re in the same folder for this case. So it’ll break if I move them of course…
But effectively the build breaks because you didn’t click an optional button?