.Generated.h file not being "Created" for my C++ Classes?

Hey Guys,

Ok, I have these 2 custom C++ classes that I have ceated within the editor and did get created in Visual Studio, both header and .ccp file.

However, when it comes time to compile them, there is no .generated.h file that has been created for them, so it gives me errors.

How can I get past this?

Can I make them myself?

Does anyone know why this is happening?

Thanks,
.

Try writing



GENERATED_UCLASS_BODY()


in the header file class declaration!

2 Likes

Thank you The-Cowboy! Let me try that.

Thanks,
.

Amazingly enough, I am now facing the same error and GENERATED_UCLASS_BODY() is not helping.

Right click uproject file and generate the files from there, on windows explorer. If that doesn’t work then could be there something corrupted in project or engine installation or error on VisualStudio.
Also make sure your main header include the class you created.

Those “Intermediate” folders are the biggest annoyance of this engine ^^

UHT generates them at compile time, they don’t sit there all the time.

It will only generate it you have a reflected type in the header file, e.g. a UCLASS, USTRUCT etc.

So I am still getting the file not found error



Performing 4 actions (4 in parallel)

@progress 'Compiling C++ source code...' 0%

[1/4] Compile UTResetPostProcessVolumesCommandlet.cpp

[2/4] Compile UTResetLineUpDefaultsCommandlet.cpp

In file included from /home/the_cowboy/unrealworks/UnrealProjects/UnrealTournament/Source/UnrealTournament/Private/UTResetPostProcessVolumesCommandlet.cpp:4:

/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Developer/SourceControl/Public/SourceControlHelpers.h:10:10: fatal error: 'SourceControlHelpers.generated.h' file not found

#include "SourceControlHelpers.generated.h"

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /home/the_cowboy/unrealworks/UnrealProjects/UnrealTournament/Source/UnrealTournament/Private/UTResetLineUpDefaultsCommandlet.cpp:4:

/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Developer/SourceControl/Public/SourceControlHelpers.h:10:10: fatal error: 'SourceControlHelpers.generated.h' file not found

#include "SourceControlHelpers.generated.h"

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated.

1 error generated.



despite the fact the file is there in [FONT=comic sans ms]Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/SourceControl directory. I believe somehow the code is not finding it there. So my question which component of Engine is responsible for searching the .generated.h files. I tried searching “In file included from” string but got no results.

P.S. Qt Creator does recognize the relevant .generated.h file.

The solution is simple. I followed https://answers.unrealengine.com/questions/835703/view.html and added the following code



PublicDependencyModuleNames.AddRange(new string] {
         "SomeRequiredUTModules",
        "SourceControl"    
        });


and now it recognizes the .generated.h files.

If I can get to know what code lines in UBT or UHT are associated with this process, I can write a logic to report appropriate error which for this case is not “file not found” but “module not found”.

1 Like

Hi, I’m resurrecting this old question because I stumbled upon it and it did not solve my issue (which is pretty much what the OP posted).

I could not find any answer online but I ended up finding a surprisingly simple way… I just went into my .cpp file and added the include to my .h file and it worked :expressionless: Somehow my IDE had not added the include and I guess you need a cpp including your file for it to generate the generated.h file

When I get the issue, I generally remove Intermediate, Build, Binaries, .vs (and .idea in my case since I use Rider) and the sln file and then regenerate the project files from the .uproject file (be careful, if you have long compilation times, you’ll need a full recompilation, normally Intermediate should be enough). This does the trick for me in most cases, but not there so I thought I’d share my simple solution