Inheriting from one plugin to another

This might be trivial, but I can’t get it to work. I’m trying to inherit one class from a plugin (Plugin_Source) into another (Plugin_Target) to extend some functionalities.

I tried



#include Plugin_Source/ExamplePawn.h


But that didn’t work, what is the correct way of doing this?

Any help or pointers would be most appreciated.

Update, I was told to include the plugin/module on the ‘build.cs’ file. I can locate both xx.build.cs files corresponding for each of the two plugins, but how should I modify them so that I can include the corresponding header files to reference the “Plugin_Source” into the “Plugin_Target”?

You need to add a dependency. Look into the the build.cs of your game module

You must add Plugin_Source to “.uplugin” of Plugin_Target, to make it load with it. After Modules, like this:



"Plugins": 
        {
            "Name": "Plugin_Source",
            "Enabled": true
        }
    ]


Also, add Plugin_Source module to of Plugin_Target.Build.cs into PublicDependencyModuleNames:



        PublicDependencyModuleNames.AddRange(
            new string]
            {
                "Core",
                "Plugin_Source"
                // ... add other public dependencies that you statically link with here ...
            }
            );


and finally include Plugin_Source required headers to your code.

And the plug-in must export the class to be accessible from another dll, so the class should have PLUGIN_SOURCE_API macro on declaration header.

Could you show a code example as the other people did? There is no context to understand what you mean. Declaration header in *which *file?

It’s also worth noting that if you’re deriving from a class that’s in a plugin, you have to include the header file for every class inside the plugin that is used by the class you’re deriving from. So for example, let’s use the DirGravity plugin as an example. I wanted to derive a class from the GravityCharacter.h Inside of that, we have a forward declaration, which show’s we’ll be using this class later

class UGravityMovementComponent

So when I derive from this class, I need to include both the .h of the class I’m deriving from, and any forward-declared classes in the .h as well. Now this could also be because the class’ methods are used in the .cpp as well. I didn’t test. It honestly doesn’t matter. If it’s in the plugin and is used in the class you’re deriving from, you have to include it in your derived class’ header file.

So now, my child character’s header needs to include

#include "GravityCharacter.h"
#include "GravityMovementComponent.h"

If I don’t include those, it won’t work.

I know this is a bit old but for anyone coming in future, this is an example of what BrUno_XaVieR was suggesting:

in your PluginSource you need to add a specific macro to any Function you want to be able to use in your PluginTarget.

Imagine your PluginSource is called “MagicFun” and you have a Function called getBool() defined in your MagicFun plugin.

If you want to use the getBool Function in your PluginTarget, you need to do the following:

in the header file where you declared the function you need to add the macro MAGICFUN_API to each function you want to be able to use outside, like this:

in the .h file:

bool MAGICFUN_API getBool();

the same for a class:

UCLASS(meta=…)
class MAGICFUN_API UyourClass : public UotherClass
{
GNERATED_BODY()

}

And of course don’t forget the other steps explained by redbox

There might be other way around or a more global way, but at least this work.