Runtime/Engine/Public/ComponentInstanceDataCache.h:39:100: error: member access into incomplete type 'const UObject'

I have a simple hello world c++ plugin working, but it breaks when i include GameFramework/Actor.h with the error below. What is the correct way to define new UObjects in a plugin, what includes or build options am i missing?

[1/3] Compile Module.MyPlugin.cpp
In file included from /home/raptor/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/MyPlugin/Module.MyPlugin.cpp:2:
In file included from /home/raptor/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Private/MyPlugin.cpp:6:
In file included from ../../../Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Public/IMyPlugin.h:325:
In file included from Runtime/Engine/Classes/GameFramework/Actor.h:4:
Runtime/Engine/Public/ComponentInstanceDataCache.h:39:100: error: member access into incomplete type 'const UObject'
        const UClass* GetComponentClass() const { return SourceComponentTemplate ? SourceComponentTemplate->GetClass() : nullptr; }
                                                                                                          ^
Runtime/Core/Public/Misc/Timespan.h:11:7: note: forward declaration of 'UObject'
class UObject;
      ^
In file included from /home/raptor/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/MyPlugin/Module.MyPlugin.cpp:2:
In file included from /home/raptor/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Private/MyPlugin.cpp:6:
In file included from ../../../Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Public/IMyPlugin.h:325:
In file included from Runtime/Engine/Classes/GameFramework/Actor.h:4:
Runtime/Engine/Public/ComponentInstanceDataCache.h:39:102: error: expected ':'
        const UClass* GetComponentClass() const { return SourceComponentTemplate ? SourceComponentTemplate->GetClass() : nullptr; }
                                                                                                            ^
                                                                                                            : 
Runtime/Engine/Public/ComponentInstanceDataCache.h:39:75: note: to match this '?'
        const UClass* GetComponentClass() const { return SourceComponentTemplate ? SourceComponentTemplate->GetClass() : nullptr; }
                                                                                 ^
Runtime/Engine/Public/ComponentInstanceDataCache.h:39:102: error: use of undeclared identifier 'GetClass'
        const UClass* GetComponentClass() const { return SourceComponentTemplate ? SourceComponentTemplate->GetClass() : nullptr; }
                                                                                                            ^
Runtime/Engine/Public/ComponentInstanceDataCache.h:84:8: error: use of undeclared identifier 'USceneComponent'
        TMap< USceneComponent*, FTransform > InstanceComponentTransformToRootMap;
              ^
Runtime/Engine/Public/ComponentInstanceDataCache.h:84:24: error: expected expression
        TMap< USceneComponent*, FTransform > InstanceComponentTransformToRootMap;
                              ^
In file included from /home/raptor/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/MyPlugin/Module.MyPlugin.cpp:2:
In file included from /home/raptor/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Private/MyPlugin.cpp:6:
In file included from ../../../Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Public/IMyPlugin.h:325:
In file included from Runtime/Engine/Classes/GameFramework/Actor.h:5:
In file included from Runtime/Engine/Classes/Components/SceneComponent.h:4:
In file included from Runtime/Engine/Classes/Components/ActorComponent.h:4:
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:18:1: error: C++ requires a type specifier for all declarations
UENUM()
^
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:18:8: error: expected ';' after top level declarator
UENUM()
       ^
       ;
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:29:1: error: C++ requires a type specifier for all declarations
UENUM()
^
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:29:8: error: expected ';' after top level declarator
UENUM()
       ^
       ;
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:44:1: error: C++ requires a type specifier for all declarations
UENUM()
^
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:44:8: error: expected ';' after top level declarator
UENUM()
       ^
       ;
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:69:1: error: unknown type name 'UENUM'
UENUM(BlueprintType)
^
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:69:21: error: expected ';' after top level declarator
UENUM(BlueprintType)
                    ^
                    ;
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:73:15: error: missing ',' between enumerators
        TG_PrePhysics UMETA(DisplayName="Pre Physics"),
                     ^
                     , 
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:73:21: error: expected '= constant-expression' or end of enumerator definition
        TG_PrePhysics UMETA(DisplayName="Pre Physics"),
                           ^
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:76:17: error: missing ',' between enumerators
        TG_StartPhysics UMETA(Hidden, DisplayName="Start Physics"),
                       ^
                       , 
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:76:18: error: redefinition of enumerator 'UMETA'
        TG_StartPhysics UMETA(Hidden, DisplayName="Start Physics"),
                        ^
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:73:16: note: previous definition is here
        TG_PrePhysics UMETA(DisplayName="Pre Physics"),
                      ^
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:76:23: error: expected '= constant-expression' or end of enumerator definition
        TG_StartPhysics UMETA(Hidden, DisplayName="Start Physics"),
                             ^
Runtime/Engine/Classes/Engine/EngineBaseTypes.h:79:18: error: missing ',' between enumerators
        TG_DuringPhysics UMETA(DisplayName="During Physics"),
                        ^
                        , 
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
1 Like

i was able to fix my problem by adding “CoreUObject” to my deps in …Build.cs file and in the c++ file i now include these:

#include "Runtime/UMG/Public/UMG.h"
#include "Runtime/UMG/Public/UMGStyle.h"
#include "Runtime/UMG/Public/Slate/SObjectWidget.h"
#include "Runtime/UMG/Public/IUMGModule.h"
#include "Runtime/UMG/Public/Blueprint/UserWidget.h"
#include "AIController.h"
#include "Components/AudioComponent.h"
#include "AudioDecompress.h"
#include "AudioDevice.h"
#include "ActiveSound.h"
#include "Audio.h"
#include "Developer/TargetPlatform/Public/Interfaces/IAudioFormat.h"
#include "VorbisAudioInfo.h"
1 Like