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.


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.


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?

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.