Quantcast
Channel: Questions in topic: "native plugin"
Viewing all articles
Browse latest Browse all 376

What is the correct location for a native (C++) plugin's DLL dependencies

$
0
0
I have built a native Unity plugin (for deployment on Windows) in C++. This plugin (a DLL) itself depends on a number of other DLLs. So for example let's call my plugin MyPlugin.dll, and assume it depends on another DLL called Dep.dll. I understand that MyPlugin.dll should go into the Assets/Plugins/x86 folder (it's a 32 bit plugin in my case). The question is what is the right location for Dep.dll. Assume that Dep.dll is not in my system path. As far as I can tell there are two options: 1. Place Dep.dll in the root folder of the project 2. Place Dep.dll alongside my plugin in Assets/Plugins/x86 For running in the Unity Editor, both options work. However, interestingly when trying option (1) Unity prints the following error to debug console (but besides the appearance of the error, it actually still works!) > Failed to load 'Assets/Plugins/x86/MyPlugin.dll' with error 'The specified module could not be found. ', GetDllDirectory returned ''. If GetDllDirectory returned non empty path, check that you're using SetDirectoryDll correctly. Things get more complicated when building & deploying the standalone Windows application. If I use option (2) above then the DLLs get deployed to APP_Data/Plugins (assuming APP is the deployed application name). And the app doesn't work because Dep.dll presumably is not found at runtime. (The way I can make this work is to create a batch file which first appends APP_Data/Plugins to the system path, prior to running the app). Alternatively if Dep.dll is kept alongside the app's EXE then it does work, though aesthetically it would be nicer if I could hide Dep.dll in the plugins folder with the rest of the DLLs So I guess my question is whether there is some way (using SetDllDirectory?) to allow me to keep Dep.dll with all other DLLs under the plugins folder, and still have it found at runtime, without having to add it to system path using a wrapper batch file or anything? Thanks

Viewing all articles
Browse latest Browse all 376

Latest Images

Trending Articles



Latest Images