Compiling a UEdGraph class in a plugin with UCLASS() fails

This post is copied from the Unreal Engine Forums. Link:

Hi everyone!

I’m currently attempting to extend the graphical editors of the engine to allow me to create and modify some custom asset files in a Blueprint-like environment. I’ve got my plugin set up, and I can create new factories of my asset type. However, when I began work on creating the actual editor, I ran into some issues.

I can create a class derived from UEdGraph fine, and it will compile as expected until I add the UCLASS() macro with its corresponding GENERATED_BODY(). When these two lines are present in the file, the compilation fails with this error:

Reflection code generated for DialogueGraphProjectEditor in 5.5658969 seconds
Performing 3 actions (8 in parallel)
[1/3] Compile DialogueGraph.cpp
In file included from /home//Documents/Unreal Projects/DialogueGraphProject/Plugins/DialogueEditor/Source/DialogueEditor/Private/DialogueGraph.cpp:2:
/home//Documents/Unreal Projects/DialogueGraphProject/Plugins/DialogueEditor/Source/DialogueEditor/Private/DialogueGraph.h:9:1: error: unknown type name 'Engine_Source_Editor_UnrealEdMessages_Classes_FileServerMessages_h_9_PROLOG'
UCLASS(Abstract, MinimalAPI)
/home//Programming/UnrealEngine/Engine/Source/Runtime/CoreUObject/Public/UObject/ObjectBase.h:576:21: note: expanded from macro 'UCLASS'
/home//Programming/UnrealEngine/Engine/Source/Runtime/CoreUObject/Public/UObject/ObjectBase.h:563:37: note: expanded from macro 'BODY_MACRO_COMBINE'
/home//Programming/UnrealEngine/Engine/Source/Runtime/CoreUObject/Public/UObject/ObjectBase.h:562:43: note: expanded from macro 'BODY_MACRO_COMBINE_INNER'
<scratch space>:3:1: note: expanded from here
... snip cascading errors

I’ve included UnrealEd and GraphEditor as private dependency modules, but perhaps there’s something more I’m missing? Any help would be greatly appreciated.
These are the relevant source files:


#pragma once

#include "DialogueEditorPrivatePCH.h"
#include "GraphEditor.h"
//#include "DialogueGraph.generated.h"

UCLASS(Abstract, MinimalAPI)
class UDialogueGraph : public UEdGraph

    void RefreshGraph();
    void RemoveAllNodes();



#include "DialogueEditorPrivatePCH.h"
#include "DialogueGraph.h"

#define LOCTEXT_NAMESPACE "DialogueGraph"

void UDialogueGraph::RefreshGraph()

void UDialogueGraph::RemoveAllNodes()
    TArray<UEdGraphNode*> NodesToRemove = Nodes;
    for (UEdGraphNode* Node : NodesToRemove)


// Some copyright should be here...

#include "Core.h"
#include "Engine.h"
#include "UnrealEd.h"

#include "DialogueEditor.h"

// You should place include statements to your module's private header files here.  You only need to
// add includes for headers that are used in most of your module's source files tho

I’ve commented that out because it isn’t generated due to the mentioned error, and as such compilation fails at that stage instead of at the real error. It should most definitely be uncommented in working code :slight_smile:

Yes, a bunch of times. I’ve also cleaned the built binaries and rebuilt the entire thing from scratch.

You still got this commented out?

//#include “UDialogueGraph.generated.h”

It needed for GENERATED_BODY() to work, this is where that generated body is generated and GENERATED_BODY() macro just place it in class decleration

UCLASS() is dummy macro, it should be ignored by compiler, so not sure why you getting error from that

Did you tried to rebuild?

Can you put full error? because you cut it, paste it to pastebin :stuck_out_tongue:

Ah sry i messed up you got everything it needed in thaty log… hmmm actully error seems to be be somewhere else in BaseUObject. This kind of make me suspect it’s might be include cause.

Try removing #include “DialogueEditorPrivatePCH.h” and maybe #include “GraphEditor.h” too (but it might be ok to leave it) and forward reference if anything he say it’s missing, the core Engine stuff will be included via generated file anyway

Generally header files in UE4 don’t need includes, they usually forward reference only, which get overriden by includes in cpp files (since main function of #include is to paste file in to file)

Here: In file included from /home/jarl/Documents/Unreal Projects/DialogueGraphProject/ -

I snipped away a bit of it because it was just cascading errors due to the UDialogueGraph class not compiling.

I tried that, but unfortunately it did nothing. Same error, no change.

Solved! I got some help from enlight on the IRC - turns out having #ifndef in the headers screwed things up, as well as including the PCH in the headers. It now compiles fine :slight_smile: