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

**URL:** <https://forums.unrealengine.com/t/linking-lib-file-but-opening-file-looks-for-dll/431925>\
**Category:** Plugins\
**Tags:** dll, library, linker-error, unreal-engine, Plugins, UE4, question\
**Created:** [August 18, 2018, 8:26pm UTC](https://forums.unrealengine.com/t/linking-lib-file-but-opening-file-looks-for-dll/431925 "2018-08-18T20:26:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_b95dd82a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b95dd82a](https://forums.unrealengine.com/u/anonymous_user_b95dd82a)\
**Post date:** [August 18, 2018, 8:26pm UTC](https://forums.unrealengine.com/t/linking-lib-file-but-opening-file-looks-for-dll/431925/1 "2018-08-18T20:26:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![meetakshay99](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@meetakshay99](https://forums.unrealengine.com/u/meetakshay99)\
**Post date:** [December 21, 2018, 12:57pm UTC](https://forums.unrealengine.com/t/linking-lib-file-but-opening-file-looks-for-dll/431925/2 "2018-12-21T12:57:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [September 24, 2020, 10:55pm UTC](https://forums.unrealengine.com/t/linking-lib-file-but-opening-file-looks-for-dll/431925/3 "2020-09-24T22:55:02Z")

</div>

any comment related with this question?

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [September 25, 2020, 9:23am UTC](https://forums.unrealengine.com/t/linking-lib-file-but-opening-file-looks-for-dll/431925/4 "2020-09-25T09:23:34Z")

</div>

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

> **[FGenericPlatformProcess::GetDllHandle](https://docs.unrealengine.com/4.27/en-US/API/Runtime/Core/GenericPlatform/FGenericPlatformProcess/GetDllHandle/)**
>
> Load a DLL.

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…
