- Home /
DllNotFound when unmanaged c++ plugin library links to another unmanaged c++ library
The Setup
I have 3. party libraries, which i am using as Native Plugins in Unity:
dll's for windows (x86 only)
.so's and .a's for android
.so's and .a's for linux
I have placed these files in folder:
dlls for windows = Plugins --> x86
.so and .a for anroid = Plugins --> libs --> armeabi-v7a
.so and .a for linux = Plugins --> x86 (Same place as windows .dll's)
I am using P-Invoke to call these plugins, and at first glance this seems to work, I can build to the different platforms and Unity makes sure to copy all the necessary files to the specific platform.
The Problem
The 3. party libraries have some base libraries, when the 3. party libraries tries to use these base libraries it throws the DllNotFoundException. Even through the libraries is in the Plugins folder, and the correct files have been copied doing the build.
Workarounds
I have found this and this workaround which works on Windows, but I have not been able to get it to work on Android or Linux.
The workaround on windows (developer machine) I am using is, I manually copies the needed base libraries(.dll's) next to the .exe.
Thoughts
I see a few different possibilities on how to fix this:
manually load the base libraries before using the normal 3. party libraries (how?).
make sure the base libraries is placed correctly on the different platforms like the workaround on windows (where should they be placed?)
Does anyone know a solution to this problem?
I have tried to use Assembly.Load but it only works with managed .dll's... so that won't work either.
Here is a way to load / unload unmanaged libraries, but I am not sure if it works on other platforms than windows.
Answer by Mr-JWolf809 · May 12, 2015 at 10:50 AM
The solution to this problem, is to manually load the each base libraries before using the normal 3. party libraries.
A way to do this is to call a function in each of the base libraries using the Platform Invoke. The difficulty here is to know the name and parameters of a given function. If you can manage to find a name and parameters for just one function in each base library, you call these first, then the base libraries will be loaded and the normal 3. party libraries can be used normally.
Your answer
Follow this Question
Related Questions
Writing user define and in built method for android 0 Answers
arm64 libraries throw warning "Cannot auto detect architecture for Android plugin" 1 Answer
How to use multiple unity module or unityLibrary into native android application 0 Answers
pass texture2d or image to native android 0 Answers
Alarm app using unity c# 0 Answers