Linking .lib file, but opening file looks for .dll?

I’m trying to build a plugin called ‘Kiface’ using The Kinect 2.0 C++ SDK. I’ve added a dependancy in my plugin’s build.cs file like so:

using UnrealBuildTool;

using System.IO;
public class kiface : ModuleRules
{
	public kiface(ReadOnlyTargetRules Target) : base(Target)
	{
        LoadKinectSDK(Target);
        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
		
		PublicIncludePaths.AddRange(
			new string[] {
				"kiface/Public",
				// ... add public include paths required here ...
			}
			);

        PrivateIncludePaths.AddRange(
			new string[] {
				"kiface/Private",
				// ... add other private include paths required here ...
			}
			);
			
		
		PublicDependencyModuleNames.AddRange(
			new string[]
			{
				"Core",
				// ... add other public dependencies that you statically link with here ...
			}
			);
			
		
		PrivateDependencyModuleNames.AddRange(
			new string[]
			{
				"Projects",
				"InputCore",
				"UnrealEd",
				"LevelEditor",
				"CoreUObject",
				"Engine",
				"Slate",
				"SlateCore",
				// ... add private dependencies that you statically link with here ...	
			}
			);
		
		
		DynamicallyLoadedModuleNames.AddRange(
			new string[]
			{
				// ... add any modules that your module loads dynamically here ...
			}
			);
	}

    private string ThirdPartyPath
    {
        get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
    }

    private string ModulePath
    {
        get { return ModuleDirectory; }
    }

    public bool LoadKinectSDK(ReadOnlyTargetRules Target)
    {
        bool isLibrarySupported = false;
        if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
        {
            isLibrarySupported = true;
            string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86";
            string LibrariesPath = Path.Combine(ThirdPartyPath, "Kinect", "lib", PlatformString);
            PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "Kinect20.lib"));
            PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "Kinect20.Face.lib"));
        }
        if (isLibrarySupported)
        {
            // Include path
            PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "Kinect", "inc"));
        }
        Definitions.Add(string.Format("WITH_KINECT_SDK={0}", isLibrarySupported ? 1 : 0));
        return isLibrarySupported;
    }
}

In this file the important lines are:

PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "Kinect20.lib"));
PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "Kinect20.Face.lib"));

And my project can build successfully, but when i try and open the project via the unreal editor, it tells me:

“Plugin ‘kiface’ failed to load because module ‘kiface’ could not be loaded. There may be an operating System error or the module may not be properly set up”

When i look at the log files i find this line:

Missing import: Kinect20.dll

and

Missing import: Kinect20.Face.dll

This makes sense why the project is crashing, because only Kinect20.lib and Kinect20.face.lib exist. But i specified them as .lib in the build.cs file, why is it trying to find .dll?

Did you find any solution for this? I too am facing exact same issue… Linking .lib files but unreal looks for .dll ones.

any comment related with this question?

In your situation you need to use GetDllHandle derived from FPlatformProcess class inside of your plugin StartupModule function .cpp, this class reference has been explained very well(!) in documentation

Here is a sample

const FString BaseDir = IPluginManager::Get().FindPlugin("<your_plugin>")->GetBaseDir();
const FString PluginDir = FPaths::Combine(*BaseDir, TEXT("Source/ThirdParty"));
FString LibDirMongoCxx = FPaths::Combine(*PluginDir, TEXT("<path to your dll include your dll>"));
auto CoreHandle = FPlatformProcess::GetDllHandle(*LibDirBoost);

if CoreHandle is not null pointer, your dll loaded successfully.

Then go build.cs file of your plugin and delay your dll by

PublicDelayLoadDLLs list by

PublicDelayLoadDLLs.Add("yourverynice.dll");

If you have any concern by order of loading your dlls, please change your loading order in .cpp.

I hope this helps…