Duplicate leaf header name found

Hi all!

I was moving around .h and .cpp files and suddenly got this type of error (“Duplicate leaf header name found: %s (original: %s)”) during the compilation for several moved headers. Now I am not able to compile the project at all. I tried clearing “Intermediate” directory, regenerating project files - nothing helped me. Currently I am working with the distributed “baked” version of the engine (not source).

I guess this UObject headers are somewhere referenced and cached. This way to fix it I just need to remove the cache they are stored at.

Has anybody faced the same issue? Have you fixed it, how?

UPD 1:
I have found that a list of headers to be processed is comming from *.uhtmanifest file in the Intermediate/Build/… This file is generated each time during the project build before UnrealHeaderTool parses it, so it can’t be easily modified to remove duplications.
Currently I am searching for the place where it is generated and what data it uses to form *.uhtmanifest file.

1 Like

I guess I know why it happens. I just faced the same issue and by reading it carefully, I figured what is wrong.

I had this pair of .h and .cpp files inside my source directory:

Source/SomeProject/Some/Path{1}/SomeActor.cpp
Source/SomeProject/Some/Path{1}/SomeActor.h

Then, I added the following for keeping the enums related to that actor in a separate header file (notice Path2):

Source/SomeProject/Some/Path{2}/SomeActor.h

It gave me the same error as you. I renamed the file to:

Source/SomeProject/Some/Path{2}/SomeActorTypes.h

And, viola it’s solved. I did not even need to regenerate the project files.

I just had the same problem, and by paying closer attention I figured out I had duplicated files, see image bellow (which occured because I moved them to a different folder from remote but the original files were not deleted by VCS).

If you pay closer attention to the error message, you’ll see it’s pointing out the locations of each of the 2 files. For me, one is in the Framework folder while the other one is directly in Project folder :

Delete the undesired file (make sure you actually move it to bin, not only excluding it from project).

Regenerate .sln if needed (right-click on .uproject file → Generate Visual Studio project files).

2 Likes

Yeah, actually it was just accidental duplication of files. Thanks all for the answers!