Can't create new C++ class for plugin.

Hi there,

I’ve been trying to get some work done on a plugin, however im stuck at the very beginning: Whenever i try to create a plugin, and then create a new C++ class in it, i get this error:

What i’ve done:

  1. Created empty project

  2. Created Blank plugin, named MyPlugin

  3. Added new C++ class, UObject parent class, inside the MyPlugin(Runtime) module.

The error i get:

Launching UnrealBuildTool... [D:/Epic Games/UnrealEngine/UE_4.23/Engine/Binaries/DotNET/UnrealBuildTool.exe  -ModuleWithSuffix=MyPlugin,2890 Win64 Development -TargetType=Editor -Project="C:/Users/fabia/workspace/ue_workspace/PluginDevelopment/PluginDevelopment.uproject" -FailIfGeneratedCodeChanges "C:/Users/fabia/workspace/ue_workspace/PluginDevelopment/Plu
ginDevelopment.uproject"  -IgnoreJunk]
Invalidating makefile for PluginDevelopmentEditor (source file added)
Parsing headers for PluginDevelopmentEditor
  Running UnrealHeaderTool "C:\Users\fabia\workspace\ue_workspace\PluginDevelopment\PluginDevelopment.uproject" "C:\Users\fabia\workspace\ue_workspace\PluginDevelopment\Intermediate\Build\Win64\PluginDevelopmentEditor\Development\PluginDevelopmentEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors 
-installed -FailIfGeneratedCodeChanges
ERROR: 'C:/Users/fabia/workspace/ue_workspace/PluginDevelopment/Plugins/MyPlugin/Intermediate/Build/Win64/UE4Editor/Inc/MyPlugin/MyObject.generated.h': Changes to generated code are not allowed - conflicts written to 'C:/Users/fabia/workspace/ue_workspace/PluginDevelopment/Plugins/MyPlugin/Intermediate/Build/Win64/UE4Editor/Inc/MyPlugin/MyObject.generated.h.
conflict'
CompilerResultsLog: New page: Compilation - 05.10.2019 04:42:19
CompilerResultsLog: Invalidating makefile for PluginDevelopmentEditor (source file added)
CompilerResultsLog: Parsing headers for PluginDevelopmentEditor
CompilerResultsLog:   Running UnrealHeaderTool "C:\Users\fabia\workspace\ue_workspace\PluginDevelopment\PluginDevelopment.uproject" "C:\Users\fabia\workspace\ue_workspace\PluginDevelopment\Intermediate\Build\Win64\PluginDevelopmentEditor\Development\PluginDevelopmentEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattende
d -WarningsAsErrors -installed -FailIfGeneratedCodeChanges
CompilerResultsLog: ERROR: 'C:/Users/fabia/workspace/ue_workspace/PluginDevelopment/Plugins/MyPlugin/Intermediate/Build/Win64/UE4Editor/Inc/MyPlugin/MyObject.generated.h': Changes to generated code are not allowed - conflicts written to 'C:/Users/fabia/workspace/ue_workspace/PluginDevelopment/Plugins/MyPlugin/Intermediate/Build/Win64/UE4Editor/Inc/MyPlugin/M
yObject.generated.h.conflict'

I’ll attach the MyObject.generated.h below.

What i tried so far (which didnt work):

  • Tried manually adding classes and generating project solution after

  • Tried rebuilding project from solutoin after creating the plugin

  • Tried building as Development Editor from vs

Your help will be much appreciated, thank you in advance. <3

[It wont let me upload the file, so here’s its rather lengthy content:]

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
	Generated code exported from UnrealHeaderTool.
	DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/

#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"

PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef MYPLUGIN_MyObject_generated_h
#error "MyObject.generated.h already included, missing '#pragma once' in MyObject.h"
#endif
#define MYPLUGIN_MyObject_generated_h

#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_RPC_WRAPPERS
#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_RPC_WRAPPERS_NO_PURE_DECLS
#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_INCLASS_NO_PURE_DECLS \
private: \
	static void StaticRegisterNativesUMyObject(); \
	friend struct Z_Construct_UClass_UMyObject_Statics; \
public: \
	DECLARE_CLASS(UMyObject, UObject, COMPILED_IN_FLAGS(0), CASTCLASS_None, TEXT("/Script/MyPlugin"), NO_API) \
	DECLARE_SERIALIZER(UMyObject)


#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_INCLASS \
private: \
	static void StaticRegisterNativesUMyObject(); \
	friend struct Z_Construct_UClass_UMyObject_Statics; \
public: \
	DECLARE_CLASS(UMyObject, UObject, COMPILED_IN_FLAGS(0), CASTCLASS_None, TEXT("/Script/MyPlugin"), NO_API) \
	DECLARE_SERIALIZER(UMyObject)


#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_STANDARD_CONSTRUCTORS \
	/** Standard constructor, called after all reflected properties have been initialized */ \
	NO_API UMyObject(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); \
	DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UMyObject) \
	DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UMyObject); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UMyObject); \
private: \
	/** Private move- and copy-constructors, should never be used */ \
	NO_API UMyObject(UMyObject&&); \
	NO_API UMyObject(const UMyObject&); \
public:


#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_ENHANCED_CONSTRUCTORS \
	/** Standard constructor, called after all reflected properties have been initialized */ \
	NO_API UMyObject(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()) : Super(ObjectInitializer) { }; \
private: \
	/** Private move- and copy-constructors, should never be used */ \
	NO_API UMyObject(UMyObject&&); \
	NO_API UMyObject(const UMyObject&); \
public: \
	DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UMyObject); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UMyObject); \
	DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UMyObject)


#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_PRIVATE_PROPERTY_OFFSET
#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_12_PROLOG
#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_GENERATED_BODY_LEGACY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
	PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_PRIVATE_PROPERTY_OFFSET \
	PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_RPC_WRAPPERS \
	PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_INCLASS \
	PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_STANDARD_CONSTRUCTORS \
public: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS


#define PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_GENERATED_BODY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
	PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_PRIVATE_PROPERTY_OFFSET \
	PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_RPC_WRAPPERS_NO_PURE_DECLS \
	PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_INCLASS_NO_PURE_DECLS \
	PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h_15_ENHANCED_CONSTRUCTORS \
private: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS


template<> MYPLUGIN_API UClass* StaticClass<class UMyObject>();

#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID PluginDevelopment_Plugins_MyPlugin_Source_MyPlugin_Public_MyObject_h


PRAGMA_ENABLE_DEPRECATION_WARNINGS

You should try and provide a bit more information. Personally I can’t gauge why this is happening right now.

  1. Can you compile any non-plugin C++ code? As in, create empty project, add C++ class to the game module, compile? Is it only your class specifically that throws this error?
  2. Can you show the code for your created class (UMyObject)?
  3. Can you show the generated.h.conflict file that is generated instead of the just the generated.h file? It’s mentioned at the end of your stack.
  4. When you say you created an empty project, was it an empty Blueprint or empty C++ project? An empty Blueprint project might have some trouble with compiling if you add a C++ module - not sure about that, but it disables Hot Reload functionality for the game module if there isn’t at least a single UObject-derived C++ class present. That’s why an empty C++ project (‘Basic’) still creates a C++ game mode class for the game module.
  5. Are you using the distributed binaries or source?
1 Like