Plugin Problems

Hi,
i’m new to UE and C++ and I’m trying to write a plugin for the old Kinect.
I want to include Kinect SDK 1.8 and OpenCv, but the compiler can’t find my header files, if i set the pathes in my build file like this: PublicIncludePaths.Add(“C:/Program Files/Microsoft SDKs/Kinect/v1.8/inc/”);
If i set the include paths in my project settings, it works and i can compile, but i dont know how i build the dll file for my plugin.
I used the blank plugin and this tutorial(A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums).

PublicIncludePaths is for includes visible to users of your Plugin. PrivateIncludePaths is for includes used only by your plugin. Try putting the path into the PrivateIncludePaths instead. Also try doing a Rebuild the first time you add it.

Thanks i already tried it several times public,privat and dynamic and now it suddenly works for public. My dll problem is gone as well (Had to put some header files in #include “AllowWindowsPlatformTypes.h” brackets)

It seems i cheered too soon. I placed my includes in build files like this :

public class OpenCVLib : ModuleRules
{
public OpenCVLib(TargetInfo Target)
{
Type = ModuleType.External;

    string SDKDIR = ("C:/Program Files (x86)/opencv/build/include/");
    PublicIncludePaths.Add(SDKDIR);   
    string LibPath = ("C:/Program Files (x86)/opencv/build/x64/vc12/lib/");
    PublicLibraryPaths.Add(LibPath);
    PublicAdditionalLibraries.Add("opencv_core249d.lib");        

I dont get any errors compiling my plugin, but it still fails to load in the ue editor.
If i write my includes directly in my Project build file, studio throws some linker errors about not finding my .lib files.

I’m building a plugin that uses V8. This is my build.cs file. Hope it helps.



namespace UnrealBuildTool.Rules
{
	public class Coupling : ModuleRules
	{
        /// <summary>
        /// Accessor for the Module's path
        /// </summary>
        protected string ModulePath
        {
            get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); }
        }

        /// <summary>
        /// Accessor for thee ThirdParty Path. 
        /// </summary>
        protected string ThirdPartyPath
        {
            get { return Path.GetFullPath(Path.Combine(ModulePath, "..", "..", "ThirdParty")); }
        }

        public Coupling(TargetInfo Target)
		{
       
			PublicIncludePaths.AddRange(
				new string] {
					// ... add public include paths required here ...
		            Path.Combine(ThirdPartyPath, "v8", "include"),
				}
				);

			PrivateIncludePaths.AddRange(
				new string] {
					"Coupling/Private",
					// ... add other private include paths required here ...
		            Path.Combine(ThirdPartyPath, "v8", "include"),
		            }
				);

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

			PrivateDependencyModuleNames.AddRange(
				new string]
				{
					// ... add private dependencies that you statically link with here ...
				}
				);

			DynamicallyLoadedModuleNames.AddRange(
				new string]
				{
					// ... add any modules that your module loads dynamically here ...
				}
				);
            LoadV8(Target);
        }
      

        private bool LoadV8(TargetInfo Target)
        {
            if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
            {
                string PlatformString;
                string LibrariesPath = Path.Combine(ThirdPartyPath, "v8", "lib");

                if (Target.Platform == UnrealTargetPlatform.Win64)
                {
                    PlatformString = "x64";
                    LibrariesPath = Path.Combine(LibrariesPath, "Win64");
                }
                else
                {
                    PlatformString = "ia32";
                    LibrariesPath = Path.Combine(LibrariesPath, "Win32");
                }

                LibrariesPath = Path.Combine(LibrariesPath, "Debug");

                PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "icui18n.lib"));
                PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "icuuc.lib"));
                PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "v8_base.lib"));
                PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "v8_libbase.lib"));
                PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "v8_nosnapshot.lib"));
                PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "v8_snapshot.lib"));

                PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "v8", "Includes"));

                Definitions.Add(string.Format("WITH_COUPLING=1"));

                return true;
            }

            Definitions.Add(string.Format("WITH_COUPLING=0"));
            return false;
        }
    }
}


OK,i can’t find any difference except i’m using absolute paths. Am i missing something? Currently i have all my files in a Public folder,but i’m not sure where to load my modules(Pub,Priv,Dyn).
Right now my build file looks like this :


 PublicDependencyModuleNames.AddRange(
				new string]
				{                    
                    "CoreUObject",				
                    "Core",
                    "Engine",
                    "InputDevice",                   
                    "Slate",            // Used by InputDevice to fire bespoke FKey events
                    "InputCore",     
                    "KinectLib",
                    "OpenCVLib",
					// ... add other public dependencies that you statically link with here ...
				}
				);

	PrivateDependencyModuleNames.AddRange(
				new string]
				{                    
                    "CoreUObject",				
                    "Core",
                    "Engine",
                    "InputDevice",                   
                    "Slate",            // Used by InputDevice to fire bespoke FKey events
                    "InputCore",        // Provides LOCTEXT and other Input features
                    
                  
					// ... add private dependencies that you statically link with here ...
				}
				);

			DynamicallyLoadedModuleNames.AddRange(
				new string]
				{
                    "KinectLib",
                    "OpenCVLib"
					// ... add any modules that your module loads dynamically here ...
				}
				);           

Are “KinectLib”, “OpenCVLib” your plugins? If so, what do their build files look like?

What error message are you getting when you try to load it in the editor.

My plugin is called Kinectv1. KinectLib and OpenCVlib are my modules, which set include and library paths. They both look like:


using UnrealBuildTool;

public class OpenCVLib : ModuleRules
{    
     
    
    public OpenCVLib(TargetInfo Target)
	{
		Type = ModuleType.External;

        string SDKDIR = ("C:/Program Files (x86)/opencv/build/include/");   
	
	    PublicIncludePaths.Add(SDKDIR);          
            

            string LibPath = ("C:/Program Files (x86)/opencv/build/x64/vc12/lib/");

            PublicLibraryPaths.Add(LibPath);
            PublicAdditionalLibraries.Add("opencv_core249d.lib");
            PublicAdditionalLibraries.Add("opencv_imgproc249d.lib");
            PublicAdditionalLibraries.Add("opencv_highgui249d.lib");
            PublicAdditionalLibraries.Add("opencv_ml249d.lib");
            PublicAdditionalLibraries.Add("opencv_video249d.lib");
            PublicAdditionalLibraries.Add("opencv_features2d249d.lib");
            PublicAdditionalLibraries.Add("opencv_calib3d249d.lib");
            PublicAdditionalLibraries.Add("opencv_objdetect249d.lib");
            PublicAdditionalLibraries.Add("opencv_contrib249d.lib");
            PublicAdditionalLibraries.Add("opencv_legacy249d.lib");
            PublicAdditionalLibraries.Add("opencv_flann249d.lib");

		
	}
}

The error msg is: Plugins ‘Kinectv1’ failed to load because module ‘Kinectv1’ could not be loaded. There may be an operating system error or the module may not be properly set up.

Does your plugin have two modules? I haven’t seen any plugins that have more then 1 module. The script plugin (UE4 > Plugins > Script) has three separate plugins each with one module. You could try merging both modules into a single module.

Have you tried just getting OpenCV alone to work? OpenCV is pretty standalone and might be easier to get working.

Also, here’s a link to Bob’s Flathead module (GitHub - BobGneu/Flathead: Flathead = UE4 + Javascript) which implements V8. I used it as a basis for mine. It might help you see a working example. He used it in a sample game here: https://github.com/BobGneu/UE4FlyingGame

And if you haven’t seen in, it the UE4 source code in the Plugins > Developer folder there’s a BlankPlugin that can be used as a starting point.

I need Kinect and OpenCV, so i tried merging both modules.I don’t really know how the UE Build system works; is it normal that intellisense can’t find my header files, but compiling works? My Plugin is a mix of the blank plugin and some parts of Lion’s Kinectv2 plugin. The code is nothing special, just some basic functions for reading the Kinect data and processing it with OpenCv. The code itself works and i just need to get it in a format that ue likes and give the values to a unreal class.