I am developing a plugin and I need to link some DLLs at run-time. The project does not crash, but it does not work as expected since some DLL is not being loaded. This is the structure of my plugin:
In the .Build.cs I have linked the path of include files, .lib and .dll. I show the this file:
public class AzureKinect : ModuleRules
{
public AzureKinect(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
// Add the dependency modules
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Projects",
"Engine",
"InputCore",
"RenderCore",
"RHI"
});
string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "amd64" : "x86";
string ThirdPartyPath = Path.Combine(ModuleDirectory, "..", "..", "ThirdParty");
// Add the include path
PublicIncludePaths.AddRange(
new string[]
{
Path.Combine(ThirdPartyPath, "Azure Kinect Body Tracking SDK", "Include"),
Path.Combine(ThirdPartyPath, "Azure Kinect SDK v1.3.0", "Include")
});
// Add the import library
PublicAdditionalLibraries.AddRange(
new string[]
{
Path.Combine(ThirdPartyPath, "Azure Kinect Body Tracking SDK", "Lib", PlatformString, "k4abt.lib"),
Path.Combine(ThirdPartyPath, "Azure Kinect SDK v1.3.0", "Lib", PlatformString, "k4a.lib"),
Path.Combine(ThirdPartyPath, "Azure Kinect SDK v1.3.0", "Lib", PlatformString, "k4arecord.lib")
}
);
PublicDelayLoadDLLs.AddRange(
new string[]
{
"cublas64_100.dll",
"cudart64_100.dll",
"cudnn64_7.dll",
"depthengine_2_0.dll",
"dnn_model_2_0.onnx",
"k4a.dll",
"k4abt.dll",
"k4arecord.dll",
"onnxruntime.dll"
}
);
// Ensure that the DLL is staged along with the executable
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/cublas64_100.dll"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/cudart64_100.dll"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/cudnn64_7.dll"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/depthengine_2_0.dll"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/dnn_model_2_0.onnx"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/k4a.dll"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/k4abt.dll"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/k4arecord.dll"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "..", "..", "Binaries/Win64/onnxruntime.dll"));
}
}
If I include all these dlls in my environment variable’s path, the project works as expected, but I want to link these dlls from the plugin in a programmatic way.