Hi all,
I am working on a HoloLens2 project which uses some WinRT APIs, which are really nasty to have in UE. I therefore decided to put the code in a DLL with a minimal interface. The UE part using this code is currently in a project plugin, which I intend to reuse in the future.
After some time and reading Adding third party DLL path for plugin, I got the build stuff somewhat working by adding PublicIncludePaths, PublicAdditionalLibraries, RuntimeDependencies and PublicDelayLoadDLLs. I have also added PushDllDirectory for the third-party directory and added my plugin in the uproject file of the containing development project. I can also see that all of the referenced DLLs are copied to the binary directory (of the plugin) when building.
Nevertheless the editor crashes on startup in d:\a01_work\2\s\src\vctools\delayimp\delayhlp.cpp:312 stating that it could not load the third-party DLL.
If I start from Visual studio with the debugger attached, I can see that a breakpoint in StartupModule is not hit before the crash in delayhlp occurs. As the ‘hmod’ variable there is NULL, I think the DLL was actually not found.
But why? Any ideas to troubleshoot and fix that?
Thanks in advance,
Christoph
In the meantime, I found that by copying the third-party DLL to the binary folder of the project, I can make it work, so I want to rephrase my question: how can I modify the build system such that the dependencies of the plugin are deployed with the project using the plugin?
I think the root problem is that if I place an actor using my plugin, the editor tries to access my code before StartupModule was called and modified the DLL search path.
OK, I think I made some progress: After changing the “LoadingPhase” of the 3rd-party module in my plugin from “Default” to “PreDefault” and leaving the module with the UE content on “Default”, it seems to reliably start in the editor even after a clean build. Furthermore, it copies the 3rd-party DLLs into the binary directory of HoloLens when packaging. Unfortunately, it does not compile anymore for HoloLens, but I hope I can figure that out soon …
OK, I finally got it working:
- Add a plugin to the game. The plugin initially holds one module (“MyModule”), which will host the UE part of the solution.
- Add a second module (“MyExternal”) to the plugin (new folder structure and additional entry in “Modules” array in uplugin file). This module defines the dependency on the non-UE third-party content.
- In the Build.cs of “MyExternal”, do not set the Type to ModuleType.External as the documentation suggests (it did not build for me when doing that, probably because it did not expect a IModuleInterface). Add the full include path to “PublicIncludePaths”, the import libraries to “PublicAdditionalLobraries” and the DLL to “RuntimeDependencies” and “PublicDelayLoadDLLs”.
- In the IModuleInterface of “MyExternal”, load the third-party DLL using FPlatformProcess::GetDllHandle().
- In the Build.cs of “MyModule”, add “MyExternal” as “PrivateDependencyModuleNames”.
In this constellation, everything gets copied and packaged as expected in my case.