I made a Unity3d project working with C/C++ Dll. So first I made the dll in Visual studio.
// mydll.cpp
#define EXPORT_API __declspec(dllexport)
extern "C" {
int EXPORT_API add(int a, int b)
{
return a+b;
}
}
And I added this dll into my Unity3D project and called
// C# script in Unity3D
public class TestDll : MonoBehaviour
{
[DllImport("mydll")]
private static extern int add (int a, int b);
void Start() {
int a = add (100, 200);
}
}
This code works well and I got the correct result in Unity3D editor.
So I built this project to android platform and got an apk. I installed and run this apk on my android device but the app doesn’t work. The app didn’t run the Dll function.
Whats the matter? I tried to find out the solution in Google and here, but didn’t get anything, yet. Please help me. Thanks.