Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 Cambesa · Dec 22, 2017 at 03:46 PM · androiddlllibrarydll errordllimport

DLLs work on Windows but not on Android

Dear Unity community,

I'm trying to use OpenSSL in our project but it only works for Windows. This OpenSSL solution is using libeay32.dll , ssleay32.dll and a C# .net 3.5 wrapper called ManagedOpenSsl.dll Does someone know how to make this work for Android too? When the encryption method is called, it does not encrypt and I see these errors in logcat:


12-22 16:27:40.081 13134 13172 D Unity : Unable to lookup library path for 'libeay32', native render plugin support disabled.
12-22 16:27:40.081 13134 13172 E Unity : Unable to find libeay32
12-22 16:27:40.467 13134 13172 D Unity : Unable to lookup library path for 'ssleay32', native render plugin support disabled.

12-22 16:27:40.468 13134 13172 E Unity : Unable to find ssleay32


The dll's are located in the plugins /Assets/Plugins folder, other dll's work but these do not.


Kind regards, Yorick

Comment
Add comment
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

1 Reply

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

Answer by DreadKyller · Dec 22, 2017 at 10:51 PM

These files aren't the same for each operating system. DLLs are windows-specific (without third party software)

Windows: .dll Dynamic Link Library
Linux (Android is a flavor of Linux): .so Shared Object
Mac: .dylib Dynamic Libraries

Also, you can't just rename the binary either, they much be compiled for each, although it's possible to compile for one system (say Linux) from another (say Windows) with the proper software. I believe Unity does support such software, however if you got these DLLs somewhere else, you'll need to find the appropriate files for the target platform. If you compiled these DLLs yourself, you'll need to recompile to the proper format, plenty of info online regarding how to do so.

Comment
Add comment · Show 6 · 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 Cambesa · Dec 22, 2017 at 11:37 PM 0
Share

Thank you very much. I've noticed something in the App.config of the repository.


 <dllmap os="osx" dll="libeay32" target="libcrypto.1.0.0.dylib"/>
 <dllmap os="osx" dll="ssleay32" target="libssl.1.0.0.dylib"/>
 <dllmap os="!windows,osx" dll="libeay32" target="libcrypto.so"/>
 <dllmap os="!windows,osx" dll="ssleay32" target="libssl.so"/>

So I'm wondering, will it work if I add a dllmap targeting Android to use libcrypto.so and libssl.so ? Sound to me that's a step in the right direction, but then there's the possiblity that I need to build the dll's on Android or perhaps I should build the dll's on Linux if Android is a flavor of Linux. To make it even more complicated, this should also work on iPhones and iPads.

avatar image Cambesa · Jan 02, 2018 at 09:32 AM 0
Share

I Think just building for android/linux should do the trick because the ddlmaps refer to libcrypto.so and libssl.so

avatar image Cambesa · Jan 02, 2018 at 04:17 PM 0
Share

Update: I've used a linux virtual box with CentOS 7 to get the .so files. It coincidentally had the exactly right version of OpenSSL installed(1.0.2k) but it could not find libcrypto.so or libssl.so so I used "yum provides libcrypto.so.10" to find out how to get these files on the virtual machine. After installing it "yum install libcrypto.so.10" I could use "find / -name libcrypto.so.10" and "find / -name libssl.so.10" to discover where these files were located. They were called libcrypto.so.1.0.2k and libssl.so.1.0.2k. I transfered the 32bit and 64bit versions to my work computer using ftp, removed ".1.0.2k" from all of them so they had the neutral libcrypto.so and libssl.so names as desired by the configuration file in the git repostory in my first post. I dropped them in the appropriate directory in my unity project:
Assets/Plugins/Android/libs/x86/
Assets/Plugins/Android/libs/armeabi-v7a/
Then I built the project for android and checked adb logcat for any errors and ufortunately it gave me the exact same errors described in my first post.
I feel like I'm getting very close but it still does not work. Is there anyone who can help me out a little bit more? Thanks in advance

avatar image Cambesa · Jan 03, 2018 at 03:36 PM 0
Share

Update: I've edited the $$anonymous$$anagedOpenSSL dll to skip the dllmap configuration. I think that only works when used outside of Unity. I built two ($$anonymous$$anagedOpenSSL) dll's one that searches for the windows libraries and one that searches for the android libraries. const string DLLNA$$anonymous$$E = "crypto"; Is used on android and DLLNA$$anonymous$$E is used in every [DllImport] attribute which would link the native C methods to C# calls. The actual "dll's" are called libcrypto.so and libssl.so but to make it work for Android people should remove the lib part and extension which results in calls to crypto and ssl. At this moment, OpenSSL works on Windows in the Unity editor. On Android however, I get a number of errors:

01-03 15:32:50.743 2573 2616 D Unity : Unable to load library '/system/lib/libcrypto.so', native render plugin support disabled: java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libcrypto.so" needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
01-03 15:32:50.744 2573 2616 E Unity : Unable to find crypto 01-03 15:32:51.276 2573 2616 D Unity : Unable to load library '/system/lib/libssl.so', native render plugin support disabled: java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libssl.so" needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
01-03 15:32:51.277 2573 2616 E Unity : Unable to find ssl
01-03 15:32:51.312 2573 2616 E Unity : DllNotFoundException: crypto

It seems to search for libcrypto.so(the right name) in /system/lib/ which to me sounds like it's not loading it from the one I've added to the Unity folder but it's actually searching for it on the device. How would I link that back to the one I've actually added to the Unity project?

@Dread$$anonymous$$yller Could you maybe clarify a bit more about the problem and possible solution?

Thanks in advance

avatar image Cambesa · Jan 03, 2018 at 04:23 PM 0
Share

I've moved the entire $$anonymous$$anagedOpenSLL source code to my Unity project to be able to use Unity's platform dependent compilation. Changed the const string part to:
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
const string DLLNA$$anonymous$$E = "libeay32";
const string SSLDLLNA$$anonymous$$E = "ssleay32";
#elif UNITY_ANDROID || UNITY_STANDALONE_LINUX
const string DLLNA$$anonymous$$E = "crypto";
const string SSLDLLNA$$anonymous$$E = "ssl";
#elif UNITY_IOS || UNITY_STANDALONE_OSX
no support yet
#endif

It works on Windows but when I run this on android I get the exact same error as in the previous comment. It's still searching for the /system/lib/libcrypto.so ins$$anonymous$$d of loading it from Unity.

Show more comments

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.

Follow this Question

Answers Answers and Comments

155 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

Related Questions

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Getting SSH.NET to work in Unity 1 Answer

How do I reference multiple dll files? 0 Answers

How to use Custom DLL for Hololens 0 Answers

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges