Download

How to properly create plugin that is dependent on another plugin's code ?

I have built an Eigen(Eigen) - Library plugin.
Here is it:


public class EigenPlugin : ModuleRules
{
public EigenPlugin(ReadOnlyTargetRules Target) : base(Target)
{

PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

PublicIncludePaths.AddRange(
new string] {
"EigenPlugin/Public",
// ... add public include paths required here ...

}
);

PrivateIncludePaths.AddRange(
new string] {
"EigenPlugin/Private",
// ... add other private include paths required here ...
"../Include"
}
);

Then I can simply test and use this plugin directly like this via building blue print:


#include "EigenBPFunctionLibrary.h"
#include "EigenPlugin.h"
#include <Eigen/Dense>

using Eigen::MatrixXd;

void UEigenBPFunctionLibrary::HelloEigen()
{
MatrixXd m(2, 2);
m(0, 0) = 3;
m(1, 0) = 2.5;
m(0, 1) = -1;
m(1, 1) = m(1, 0) + m(0, 1);

UE_LOG(EigenLog, Display, TEXT("
 Simple Eigen matrix values (row-wise) are : %f %f %f %f 
"), m(0,0), m(0,1), m(1,0), m(1,1));

MatrixXd m2 = MatrixXd::Random(3, 3);
UE_LOG(EigenLog, Display, TEXT("
 Displaying a random matrix of size 3 x 3. 
"));
UE_LOG(EigenLog, Display, TEXT("
 Random matrix values (row-wise) are : %f %f %f %f %f %f %f %f %f 
"), m2(0, 0), m2(0, 1), m2(0, 2), m2(1, 0), m2(1, 1), m2(1, 2), m2(2, 0), m2(2, 1), m2(2, 2));
}


Now suppose I want to build another plugin, say TestVectorLibrariesPlugin, that will depend on Eigen and couple of other libraries. How do I build this ? I made a TestVectorLibrariesPlugin.uplugin entries like this :


"Plugins": 
{
"Name": "EigenPlugin",
"Enabled": true
},
{
"Name": "AnotherVectorPlugin",
"Enabled": true
},


Now when I try to include in the TestVectorLibsPlugin like this :


#include <Eigen/StdVector>

I get,

Do I need to explicitly mention where the header files are ? Doesn’t the dependencies declarations in the plugin makes the proper includes available ?

StdVector.h should be inside EigenPlugin/Source/Public/Eigen/ the you would use



#include  "Eigen/StdVector.h"


If the header you’re adding that in is within another folder under Source/Public/ , such as EigenPlugin/Source/Public/MyAnotherFolder/ then you’d do:



#include  "../Eigen/StdVector.h"


If you want to include just “StdVector.h” without path info then your Build.cs also needs to declare that Eigen folder as public:



PublicIncludePaths.Add(Path.Combine(ModuleDirectory,"Public"));
PublicIncludePaths.Add(Path.Combine(ModuleDirectory,"Public/Eigen"));


Hi [USER=“434”]BrUnO XaVIeR[/USER] maybe I was not sufficiently clear. Here is how my Eigen plugin is organized. See (1). I did try to declare the Eigen folder in my plugin as public as you suggested.



PublicIncludePaths.AddRange(
            new string] {
                "EigenPlugin/Public",
                // ... add public include paths required here ...
                "../Include"
            }
            );


        PrivateIncludePaths.AddRange(
            new string] {
                "EigenPlugin/Private",
                // ... add other private include paths required here ...
                "../Include"
            }
            );


But I get the same error, when I try to use it in another plugin even when I do this in its Build.cs



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


And this in its .uplugin :


{
  "FileVersion": 3,
  "Version": 1,
  "VersionName": "1.0",
  "FriendlyName": "VectorLibsPlugin",
  "Description": "This is an Unreal Engine 4 plugin for usage of different vector Libraries ",
  "Category": "Other",
  "CreatedBy": "Syed Alam Abbas",
  "CreatedByURL": "https://github.com/syedalamabbas",
  "DocsURL": "",
  "MarketplaceURL": "",
  "SupportURL": "",
  "CanContainContent": true,
  "IsBetaVersion": false,
  "Installed": false,
  "Modules": 
    {
      "Name": "VectorLibsPlugin",
      "Type": "Developer",
      "LoadingPhase": "Default"
    }
  ],

  "Plugins": 
    {
      "Name": "EigenPlugin",
      "Enabled": true
    },


The question is then, how do we get the Include folder that has the Eigen directory to be available in another plugin without explicitly mentioning the full header path ?

With that file structure you should add whatever headers the library has to its “EigenPlugin.h” then for the game module or another plugins you just *#include “EigenPlugin.h” *without folders.
Looking at that screenshot, “Eigen/” folder doesnt exist and “StdVector.h” also doesn’t exist in the Source folder.
Everything C++ must be within the Source folder for a plugin; if you have external libraries then they have to go into a Source/ThirdParty folder and the code to link them is different.

I read in the documentation this can’t or shouldn’t be done. No plugin can depend on other plugin.

I need this too, I have 3 plugins that interconnect to each other, and they need to know about the others, since they are sold separately…

That documentation is old, outdated.

https://answers.unrealengine.com/questions/745416/plugins-can-not-user-another-plugins.html

This is outrageous. I have no other way to feel about Unreal Engine. It’s hard to work here if they have nobody working on updating the docs and fixing the answer hub mess… Thanks.

Hey,

I’m a little bit late, but this link might help next visitors here : https://wiki.unrealengine.com/Plugin…n_Your_Project

Have fun,