Error in plugin, Source file is not including headers. We expect...

Hello,

I am trying to create a plugin with a UObject derived class in it just like the UObjectPlugin example which is including in the engine/plugin folder. I am however facing a problem which I just cannot solve.

I am using engine version 4.9.2. When I try to build I get the following error:

Error 1 error : Source file “C:…\PluginTest\Plugins\SomePlugin\Source\SomePlugin\Private\TestObject.cpp” is not including any headers. We expect all modules to include a header file for precompiled header generation. Please add an #include statement. C:…\PluginTest\Intermediate\ProjectFiles\EXEC PluginTest

I tried adding the UObjectPlugin example to my project instead of the engine/plugin folder and it compiles just fine so I tried changing my own plugin to be completely identical to the UObjectPlugin example with the exception of some of the names. All files are the same/uses same includes. Header files are placed identically as well however it is all to no avail. I cannot compile my own plugin.

The class I am trying to compile:


header

#pragma once

#include "TestObject.generated.h"

UCLASS()
class UTestObject : public UObject
{
	GENERATED_BODY()
};

source

#include "SomePluginPrivatePCH.h"
#include "TestObject.h"

Module:



header

#pragma once

#include "ModuleManager.h"

class FSomePlugin : public IModuleInterface
{
public:

	/** IModuleInterface implementation */
	virtual void StartupModule() override;
	virtual void ShutdownModule() override;
};

source

#include "SomePluginPrivatePCH.h"

void FSomePlugin::StartupModule()
{
	// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
}

void FSomePlugin::ShutdownModule()
{
	// This function may be called during shutdown to clean up your module.  For modules that support dynamic reloading,
	// we call this function before unloading the module.
}
	
IMPLEMENT_MODULE(FSomePlugin, SomePlugin)

Any help would be appreciated.

Hi there!

I have a wiki with plugin example code here:

Plugin, Functional Code Template For You!


**Plugin Symbol Export**

Make sure to include YOURPLUGINNAME_API on your class if you want to enable projects to subclass your special UObject



```


UCLASS(ClassGroup=Rama, meta=(BlueprintSpawnableComponent))
class RAMAMELEEPLUGIN_API URamaMeleeWeapon : public USkeletalMeshComponent
{
	GENERATED_BODY()
public:
	URamaMeleeWeapon(const FObjectInitializer& ObjectInitializer); 


```


Then projects have to include your plugin as a dependency in the build cs

[More info about Rama Melee Plugin here](http://ue4code.com/melee_weapon_system_plugin_per_bone_collision_accuracy)

Enjoy!

Rama

Hello thanks for the reply. I actually already did all that and successfully inherited from the object that was included in the UObjectPlugin. My own however kept making that error. I got the error simply by adding the plugin to the public dependencies in build.cs without ever using it.

Well I tried creating a new plugin again and it works. I went back to the other and now that also works. I don’t recall changing anything. Maybe my computer just needed to cool down over night. I hope you understand that was sarcasm:P

Anyways it works but I have no clue why which is a bit annoying but if I never see that weird error again I guess all is good.

Btw I was wondering if there is something special about the PrivatePCH.h or could I just delete or rename it if I wanted to?(Not that I have a need to). Also what does PCH stand for?

Thanks.