How can I package runtime dependencies from an engine plugin?


I've created a runtime engine plugin that links against some third party dlls. I've included the third party dlls inside Engine\Plugins\<"pluginname">\Binaries\\ so they are picked up and loaded automatically (I can't just delay load them due to limitations in the libraries I'm trying to link against).
I've also added these dlls as runtime dependencies in my Build.cs file.

The problem comes when I package a game that uses this engine plugin. I end up with the following folder structure:

Engine/Plugins/<"PluginName">/Binaries/<"platform">/ Third party dlls
<"ProjectName">/Binaries/<"platform">/.exe
.exe

As soon as I run the exe, it fails to find and load the third party dlls unless I manually copy them into <“ProjectName”>/Binaries/

What is best practice for packaging third part dlls from an engine plugin when building a game?

Sorry to bump this, but any help would be massively appreciated

You can add a runtime dependency in your Build.cs configuration file. There is a constructor of RuntimeDependency that receives two parameters: InPath and InSourcePath, where InPath is the path that will be used by the game to find the DLL and InSourcePath is the path the UnrealBuildTool will use to find the DLL in order to copy it the the game’s build folder.

So in order to package the plugin DLL next to the game executable, you just need to add the following line:

RuntimeDependencies.Add(@“$(TargetOutputDir)/<“Thirdparty”>.dll”, @“$(PluginDir)/Binaries/<“platform”>/<“Thirdparty”>.dll”);

Checkout Runtime Dependencies section for more path variables: Third-Party Libraries | Unreal Engine 4.27 Documentation