Hello guys,
in order to make use of third party libraries in Unity I am currently trying to load a simple C++ library to my Unity project.
The C++ library consists of a single function that returns a random number.
I've built the DLL file via Visual Studio 2022 (new Dynamic-Link Library Project) and drag and dropped the resulting DLL file into Assets/Plugins
(I also tried Assets/Plugins/Android
and Assets/Plugins/Android/x86_64
).
My Plugin-Inspector looks like this:
In my simple project I'm calling the function upon pressing a button to change the text of a text-field. However when I press the button I receive the following error:
Error messages from Android Logcat
2023/12/08 13:57:53.500 32535 32559 Error Unity DllNotFoundException: Unable to load DLL 'SampleNativeProject.dll'. Tried the load the following dynamic libraries: Unable to load dynamic library 'SampleNativeProject.dll' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "SampleNativeProject.dll" not found
2023/12/08 13:57:53.500 32535 32559 Error Unity at NativeSampleScript.getRandomNumber () [0x00000] in <00000000000000000000000000000000>:0
2023/12/08 13:57:53.500 32535 32559 Error Unity at NativeSampleScript.GetRandomNumberFromNative () [0x00000] in <00000000000000000000000000000000>:0
2023/12/08 13:57:53.500 32535 32559 Error Unity at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0
2023/12/08 13:57:53.500 32535 32559 Error Unity at MixedReality.Toolkit.StatefulInteractable.OnLastSelectExited (UnityEngine.XR.Interaction.Toolkit.SelectExitEventArgs args) [0x00000] in <00000000000000000000000000000000>:0
2023/12/08 13:57:53.500 32535 32559 Error Unity at UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) [0x00000] in <00000000000000000000000000000000>:0
2023/12/08 13:57:53.500 32535 32559 Error Unity at UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable.OnSelectExited (UnityEngine.XR.Interaction.Toolkit.SelectExitEventAr
I'm using the following versions:
Unity Editor version: 2022.3.2f1
ML2 OS version: 1.4.1
MLSDK version: 1.4
Host OS: Windows 10
Edit v1: I have a feeling I should build my library with Android Studio instead of Visual Studio, does it matter?
Thanks in advance for any help, let me know if more information is needed.
Batu