• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ninjafishnz · Jul 20, 2020 at 10:04 AM · androidandroid builddlldllnotfoundexceptiondllimport

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!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JayPatoliyaBeetonz · Jan 29 at 06:55 AM 0
Share

have you ever find x64 libOpenCvSharpExtern.so with success build?

avatar image ninjafishnz JayPatoliyaBeetonz · Feb 07 at 10:44 PM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MichaelSolerBeatty · Jan 31 at 05:54 AM 1
Share

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

avatar image ninjafishnz MichaelSolerBeatty · Feb 07 at 10:42 PM 0
Share

Given it's been over 6 months I'm afraid I don't remember how I did it. The vague steps were:

  1. Go to this GitHub repo and get the plugin's source code

  2. 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 terminal 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 mingw-w64-x86_64-cmake <- here not the mingw-w64-x86_64 part, it's ugly but necessary pacman -S mingw-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/Terminal), 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!

avatar image FaiyazOfficial · Feb 05 at 12:20 PM 0
Share

Great. Can you let us know how to create .so file for a platform ?

avatar image ninjafishnz FaiyazOfficial · Feb 07 at 10:44 PM 0
Share

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.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

288 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

use [DllImport("xxxx")] for .so with other .so 0 Answers

How to use Custom DLL for Hololens 0 Answers

Get Exception DLL Not Found 0 Answers

How to properly use my own DLLs in Unity? 2 Answers

DLL plugins unsupported for Android Application Building 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges