Hi Unreal forums! I am using a pre-built C++ library in my project using dynamic library files. The library is contained in a plugin, let’s call it MyPlugin
. Building/packaging/playing in editor works fine.
However, a packaged build doesn’t start, giving the following error: Code execution cannot proceed, MyPluginLib.dll was not found
. This is due to the fact that the packaging process places MyPluginLib.dll
file in MyProject\Plugins\MyPlugin\Binaries
. However, the execution process is seemingly looking for it in MyProject\Binaries
– moving the library there manually solves this issue.
Why doesn’t the execution find the library dll in the first folder? Is there something wrong in the build.cs, or my folder structure?
The folder structure of the plugin folder is as follows:
- Includes in
Plugins\MyPlugin\Source\ThirdParty\MyPluginLib\
- Binaries in
Plugins\MyPlugin\Binaries\(PLATFORM)\
The plugin’s Build.cs looks like this:
public class MyPlugin : ModuleRules
{
public MyPlugin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
string PluginRoot = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", ".."));
string PlatformString = Target.Platform.ToString();
string LibraryDirectory = Path.Combine(PluginRoot, "Binaries", PlatformString);
PublicIncludePaths.Add(Path.Combine(PluginRoot, "Source", "ThirdParty", "MyPluginLib"));
if ((Target.Platform == UnrealTargetPlatform.Win64))
{
PublicAdditionalLibraries.Add(Path.Combine(LibraryDirectory, "MyPluginLib.lib"));
RuntimeDependencies.Add(Path.Combine(LibraryDirectory, "MyPluginLib.dll"), StagedFileType.NonUFS);
}
else if (Target.Platform == UnrealTargetPlatform.Linux)
{
// linux binaries...
}
}
Would appreciate any help.