- Home /
Android 64-bit .so DLL file not found error
Hello,
I am trying to update an older plugin to work for Android 64 bit builds, and am running into problems. Namely, I am trying to update the "OpenCV + Unity" plugin, and I have already created a 64bit "libOpenCvSharpExtern.so" file by editing the repo here.
The file I have created is available here. I have checked using MSYS2 "file" commands that the file is a 64bit build file, which all seems to be correct, as far as I can tell. I have then added the file to "/Assets/../Plugins/Android/arm64-v8a/libOpenCvSharpExtern.so".
By my understanding, this should work. Instead, the .so file is not added to my APK and the DLL cannot be found, resulting in the error:
<i>AndroidPlayer(ADB@127.0.0.1:34999)</i> DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.
at OpenCvSharp.NativeMethods.core_Mat_sizeof () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods.TryPInvoke () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods..cctor () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.OCRHMMDecoder+ClassifierCallback..ctor (System.String fileName, OpenCvSharp.CvText+OCRClassifierType type) [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.Demo.AlphabetOCR..ctor (System.Byte[] model) [0x00000] in <00000000000000000000000000000000>:0
at molAR.Start () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as OpenCvSharpException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.
*** An exception has occurred because of P/Invoke. ***
Please check the following:
(1) OpenCV's DLL files exist in the same directory as the executable file.
(2) Visual C++ Redistributable Package has been installed.
(3) The target platform(x86/x64) of OpenCV's DLL files and OpenCvSharp is the same as your project's.
System.DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.
at OpenCvSharp.NativeMethods.core_Mat_sizeof () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods.TryPInvoke () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods..cctor () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.OCRHMMDecoder+ClassifierCallback..ctor (System.String fileName, OpenCvSharp.CvText+OCRClassifierType type) [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.Demo.AlphabetOCR..ctor (System.Byte[] model) [0x00000] in <00000000000000000000000000000000>:0
at myCode.Start () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods.TryPInvoke () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods..cctor () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.OCRHMMDecoder+ClassifierCallback..ctor (System.String fileName, OpenCvSharp.CvText+OCRClassifierType type) [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.Demo.AlphabetOCR..ctor (System.Byte[] model) [0x00000] in <00000000000000000000000000000000>:0
at myCode.Start () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as TypeInitializationException: The type initializer for 'OpenCvSharp.NativeMethods' threw an exception.
at OpenCvSharp.OCRHMMDecoder+ClassifierCallback..ctor (System.String fileName, OpenCvSharp.CvText+OCRClassifierType type) [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.Demo.AlphabetOCR..ctor (System.Byte[] model) [0x00000] in <00000000000000000000000000000000>:0
at myCode.Start () [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
I have also tried to create a linker file based on another answer on this site, the file is called "link.dll" and has the below contents, which are quite possibly wrong:
<linker>
<assembly fullname="libOpenCvSharpExtern" preserve="all"/>
</linker>
What am I doing wrong here? I am quite new to all this and likely doing something silly.
Thank you in advance for your help!
have you ever find x64 libOpenCvSharpExtern.so with success build?
I managed to get it by using the file linked in other replies on this thread, and following the correct selection process I mentioned below.
But my file is incomplete, I never managed to get DLib to work for it sadly.
Answer by ninjafishnz · Jul 23, 2020 at 10:53 PM
Turns out I made a very silly mistake. You need to actually go into the Unity editor, navigate to the file in your project, and instruct Unity what platform your .so file needs to target. In my case, I needed to select the "Android 64bit" option, and then the file worked.
Problem solved.
Could you please explain how to achieve to CREATE that ".so" file in UBUNTU or windows ?
It would be interesting to share it here with the community
Thanks for your time
Given it's been over 6 months I'm afraid I don't remember how I did it. The vague steps were:
Go to this GitHub repo and get the plugin's source code
You'd need OpenCV contrib sources as well. The versions required by the plugin are listed in the plugin's repo and in the source code, so use those as reference. a. For the source - I'd go with official OpenCV GitHub repo, you can choose Branch -> Tags here and get specific version. b. Same for the OpenCV contrib c. The asset also uses DLib, I don't remember exact version, it should be is the build script code d. As for the Visual Studio version - it should work with any, but you'd need to change the target version in the build script. C$$anonymous$$ake supports up to the latest VS2019
There were a number of setup options for the ter$$anonymous$$al you needed as well. I did it on a Windows device, and these were the instructions I was given by the original developer:
You need $$anonymous$$SYS2, it will give you almost natural bash for Windows with pacman package installer. Once installed, run the following commands: pacman -S dash <- this will update one specific package pacman -Syu
<- this will update everything else, might be required to run it few times between $$anonymous$$SYS restarts (just follow console hints)Now you have the proper bash. Your Windows drives will be available as "cd /c/{path here}" or "cd /d/{path here}" with everything else being normal unix-like shell. For here you will need: pacman -S $$anonymous$$gw-w64-x86_64-cmake <- here not the $$anonymous$$gw-w64-x86_64 part, it's ugly but necessary pacman -S $$anonymous$$gw-w64-x86_64-python3 <- not sure about this one, I guess OpenCV requires it for building pacman -S git <- optional
Every -S command will install all the necessary dependencies. Once it's done, you'll have shell with git, cmake, python and everything else required to compile. Cmake will "see" your Windows compiler, i.e. Visual Studio. Try those build scripts now, the results should make more sense.
Otherwise on macOS you'll need it's usual console (Applications/Utilities/Ter$$anonymous$$al), install Homebrew (because macOS lacks package manager) and have it prepare the same git/cmake/python for you.
Even with all of these, after adding the DLib files to the source files for the plugin I could not get DLib to co-operate. So, I can offer you the best I have.
Attached is the 64 bit Android .so file, it's all you need to make it run. However, because of the lack of DLib it doesn't have DNN capabilities and, as far as I am aware, is incapable of doing face tracking. It does do computer vision to some degree, which is what I was using, primarily the image processing work.
Here is the .so file on Google Drive.
Sorry I can't be more help, but hopefully those resources allow you to get somewhere!
Great. Can you let us know how to create .so file for a platform ?
I've given an outline above, but I never managed to get the file to work exactly as intended and so it is missing some features.
The generation steps are above, but if you just wanted my file (without DNN and face tracking due to DLib not working), it is available at this link.
You still couldn't get the face tracking to work?