Can't add C++ class

I’m on 4.25.2

So I’ve tried to add a new c++ class to my project. When I add it, it said I need to recompile the project first before it can show the file. I not quite sure what it means, but if I close and re-open the project unreal will tell the “Following modules or built with a different engine version:” then it is the name of the project and it ask me to rebuild them now, which is always failed.

I’ve tried with a fresh new project, same story.

this is the error log :

Launching UnrealBuildTool… [F:/UnrealEngine/Install/UE_4.25/Engine/Binaries/DotNET/UnrealBuildTool.exe -ModuleWithSuffix=MyProject,7993 MyProjectEditor Win64 Development -Project=“F:/UnrealEngine/Project/MyProject/MyProject.uproject” “F:/UnrealEngine/Project/MyProject/MyProject.uproject” -IgnoreJunk]
Creating makefile for MyProjectEditor (no existing makefile)
ERROR: Expecting to find a type to be declared in a module rules named ‘MegascansPlugin’ in UE4Rules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null. This type must derive from the ‘ModuleRules’ type defined by Unreal Build Tool.
CompilerResultsLog: New page: Compilation - Jul. 23, 2020, 9:25:49 p.m.
CompilerResultsLog: Creating makefile for MyProjectEditor (no existing makefile)
CompilerResultsLog: ERROR: Expecting to find a type to be declared in a module rules named ‘MegascansPlugin’ in UE4Rules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null. This type must derive from the ‘ModuleRules’ type defined by Unreal Build Tool.
LogMainFrame: MainFrame: Module compiling took 0.734 seconds
LogSlate: Window ‘Message’ being destroyed
Message dialog closed, result: Yes, title: Message, text: Successfully added class ‘MyClass’, however you must recompile the ‘MyProject’ 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
LogSlate: Took 0.000167 seconds to synchronously load lazily loaded font ‘…/…/…/Engine/Content/Slate/Fonts/DroidSansMono.ttf’ (77K)

I’ve tried to deactivate the megascan plugin, but no luck.

when I try to create a new project with C++ this happen :

Running F:/UnrealEngine/Install/UE_4.25/Engine/Binaries/DotNET/UnrealBuildTool.exe Development Win64 -Project=“F:/UnrealEngine/Project/MyProject/MyProject.uproject” -TargetType=Editor -Progress -NoEngineChanges -NoHotReloadFromIDE
Creating makefile for MyProjectEditor (no existing makefile)
ERROR: Expecting to find a type to be declared in a module rules named ‘MegascansPlugin’ in UE4Rules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null. This type must derive from the ‘ModuleRules’ type defined by Unreal Build Tool.

anyone has any idea what’s going on?

Solution for me :

Turns out the MegaScan plugin was causing the problem. I uninstalled the plugin and I can now add C++ class and create a C++ project.

I’m getting this after upgrading a project from 4.24.3 and I don’t have that plugin installed anywhere (as far as I can tell). Hmmmm…

I am trying to get into C++ coding with Unreal Engine 4 and I get this error message when I try to create a C++ project (I am using Unreal Engine 4.25 and Visual Studio Community 2019 16.6.5):

The project could not be compiled. Would you like to open it in Visual Studio?

Running C:/Program Files/Epic Games/UE_4.25/Engine/Binaries/DotNET/UnrealBuildTool.exe Development Win64 -Project=“C:/Users/*****/Documents/Unreal Projects/PacktPubTest/PacktPubTest.uproject” -TargetType=Editor -Progress -NoEngineChanges -NoHotReloadFromIDE
Creating makefile for PacktPubTestEditor (no existing makefile)
@progress push 5%
Parsing headers for PacktPubTestEditor
Running UnrealHeaderTool “C:\Users*\Documents\Unreal Projects\PacktPubTest\PacktPubTest.uproject" "C:\Users*\Documents\Unreal Projects\PacktPubTest\Intermediate\Build\Win64\PacktPubTestEditor\Development\PacktPubTestEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -abslog=“C:\Users*****\AppData\Local\UnrealBuildTool\Log_UHT.txt” -installed
Reflection code generated for PacktPubTestEditor in 6.4009329 seconds
@progress pop
Building PacktPubTestEditor…
Using Visual Studio 2019 14.26.28806 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Distributing 9 actions to XGE
Fatal Error: Failed to open/create session data
Failed to open/create session data: STATUS_ACCESS_DENIED

I am trying to learn C++ and taking small steps in implementing small pieces of code from YouTube videos and other sources (I also subscribed to PacktPub.com to check out their Unreal Engine C++ books). I also know some blueprint and I am trying to replicate blueprint logic in C++.

Back around July 9 2020 I made a test project in C++ that was working fine (I could compile and I made small gameplay mechanics work) but now, after updating Visual Studio 2019 Community to 16.6.5 that project gives me errors after trying to compile it, like this log (it seems UE4 cannot “link” properly to Visual Studio now):

2020.07.25-12.58.32:675][422]CompilerResultsLog: Building FPStestjul92020Editor…
[2020.07.25-12.58.32:675][422]CompilerResultsLog: Using Visual Studio 2019 14.26.28806 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
[2020.07.25-12.58.32:675][422]CompilerResultsLog: Distributing 6 actions to XGE
[2020.07.25-12.58.32:675][422]CompilerResultsLog: Fatal Error: Failed to open/create session data
[2020.07.25-12.58.32:675][422]CompilerResultsLog: Failed to open/create session data: STATUS_ACCESS_DENIED

I am going to upgrade to UE4 4.25.2 to see if it fixes my issue.

After updating to 4.25.2 I still get the same issue, this is the log from Visual Studio:

1>------ Rebuild All started: Project: FPStestjul92020, Configuration: DebugGame x64 ------
1>Cleaning FPStestjul92020 and UnrealHeaderTool binaries…
1>Creating makefile for FPStestjul92020 (no existing makefile)
1>Parsing headers for FPStestjul92020
1> Running UnrealHeaderTool “C:\Users*\Documents\Unreal Projects\FPStestjul92020\FPStestjul92020.uproject” “C:\Users*\Documents\Unreal Projects\FPStestjul92020\Intermediate\Build\Win64\FPStestjul92020\DebugGame\FPStestjul92020.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -abslog=“C:\Users*\AppData\Local\UnrealBuildTool\Log_UHT.txt” -installed
1>Reflection code generated for FPStestjul92020 in 9.5419989 seconds
1>Building FPStestjul92020…
1>Using Visual Studio 2019 14.26.28806 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Distributing 14 actions to XGE
1>EXEC : Fatal error : Failed to open/create session data
1>Failed to open/create session data: STATUS_ACCESS_DENIED
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(54,5): error MSB3073: The command “chcp 65001 >NUL && “C:\Program Files\Epic Games\UE_4.25\Engine\Build\BatchFiles\Rebuild.bat” FPStestjul92020 Win64 DebugGame -Project=“C:\Users*\Documents\Unreal Projects\FPStestjul92020\FPStestjul92020.uproject” -WaitMutex -FromMsBuild” exited with code -1.
1>Done building project “FPStestjul92020.vcxproj” – FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

I fixed my issue, should have Googled it right away. If anybody has the same issue, in my case it was related to Incredibuild which I mistakenly installed with Visual Studio Community and did not know was a paid product (and obviously can’t use since I did not pay for it). I am still very much a beginner when it comes to Visual Studio and coding the “normal” way instead of scripting with blueprint.

So Incredibuild is on my system and causing issues with UE4 and this is what I found through Google: UE4_EXEC : Fatal error : Failed to open/create session data - Programmer Sought

**—

UE4_EXEC : Fatal error : Failed to open/create session data**

Reason for error:
Using Incredibuild but having problems
Disable incredibuild in BuildConfiguration.xml (usually located in “%AppData%\ Unreal Engine \ UnrealBuildTool \ BuildConfiguration.xml”)
If you can’t find the file, it is recommended to download an app called Evening.Everything
After the installation is complete, search for BuildConfiguration.xml directly
Then edit the file and add the following

<?xml version=“1.0” encoding=“utf-8” ?> <Configuration xmlns=“https://www.unrealengine.com/BuildConfiguration”> <BuildConfiguration> <bAllowXGE>false</bAllowXGE> </BuildConfiguration> </Configuration>


I edited the .xml file in question and now I can compile my C++ code again and things appear to be working normally.