herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 152 forks source link

How to Use MCL on Android? #89

Closed Henzi96 closed 3 years ago

Henzi96 commented 3 years ago

Hello, i would like to use MCL library on Android. I am using Android NDK to call Native C/C++ code into my App. Please can you add some Information about the correct way? Or link to a tutorial ? I was looking everywhere. Thanks

herumi commented 3 years ago

I'm sorry that I do not provide a tutorial on Android now.

There are some ways.

  1. https://github.com/herumi/bls-eth-go-binary/ provides a static library for Android, which contains mcl functions. You can use them through gomobile .

  2. https://github.com/herumi/mcl/tree/master/ffi/java provides JNI of mcl. If you can build libmcljava.so for Android by cross-compile, then you can use mcl such as https://github.com/herumi/mcl/blob/master/ffi/java/MclTest.java .

Henzi96 commented 3 years ago

Hello, thank you for your reply. I decided to choose option n.2. I am still stuck. I dont know how to create a ".so" file from link you have send me. I am a University student working on my final thesis. I really just need to use MCL library in my Android project ! Please help ! I have skype, Microsoft Teams or via Facebook call.

Dont let me die man !

po 16. 11. 2020 v 12:33 odesílatel MITSUNARI Shigeo < notifications@github.com> napsal:

I'm sorry that I do not provide a tutorial on Android now.

There are some ways.

1.

https://github.com/herumi/bls-eth-go-binary/ provides a static library for Android, which contains mcl functions. You can use them through gomobile https://github.com/golang/go/wiki/Mobile . 2.

https://github.com/herumi/mcl/tree/master/ffi/java provides JNI of mcl. If you can build libmcljava.so for Android by cross-compile, then you can use mcl such as https://github.com/herumi/mcl/blob/master/ffi/java/MclTest.java .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/herumi/mcl/issues/89#issuecomment-727922667, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARYJ2QVCQHVO55ERFAQMDYDSQEEZVANCNFSM4TWCYSNA .

herumi commented 3 years ago

I think that an Android developer can make a shared library libmcljava.so relatively easily by referring X and Y, though I've not tested it yet.

If I had time, then I'll try it, but I have many tasks now. So I'm sorry that I don't know when I can do it.

herumi commented 3 years ago

I'm making a sample of mcl on Android. https://github.com/herumi/mcl-android

Though there are some restrictions yet, I can call C++ interface.

https://github.com/herumi/mcl-android/blob/main/app/src/main/cpp/hello-libs.cpp#L39-L45

If you can solve those restrictions, could you tell me the way? I think that it is not difficult to call JNI.

Henzi96 commented 3 years ago

Its is not good for me. I need to make .so file from mcl/ffi/java/mcl_wrap.cxx for android version. Maybe ndk_build is good for me.

po 23. 11. 2020 v 12:35 odesílatel MITSUNARI Shigeo < notifications@github.com> napsal:

I'm making a sample of mcl on Android. https://github.com/herumi/mcl-android

Though there are some restrictions https://github.com/herumi/mcl-android#restriction yet, I can call C++ interface.

https://github.com/herumi/mcl-android/blob/main/app/src/main/cpp/hello-libs.cpp#L39-L45

If you can solve those restrictions, could you tell me the way? I think that it is not difficult to call JNI.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/herumi/mcl/issues/89#issuecomment-732105331, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARYJ2QQCE6VFT6DMGX5XMG3SRJCH3ANCNFSM4TWCYSNA .

Henzi96 commented 3 years ago

I need to make so file from mcl/ffi/java/mcl_wrap.cxx for android version with ndk-build Can you help me with this way?

po 23. 11. 2020 v 15:46 odesílatel Jan Strakoš jan.strakos.honza@gmail.com napsal:

Its is not good for me. I need to make .so file from mcl/ffi/java/mcl_wrap.cxx for android version. Maybe ndk_build is good for me.

po 23. 11. 2020 v 12:35 odesílatel MITSUNARI Shigeo < notifications@github.com> napsal:

I'm making a sample of mcl on Android. https://github.com/herumi/mcl-android

Though there are some restrictions https://github.com/herumi/mcl-android#restriction yet, I can call C++ interface.

https://github.com/herumi/mcl-android/blob/main/app/src/main/cpp/hello-libs.cpp#L39-L45

If you can solve those restrictions, could you tell me the way? I think that it is not difficult to call JNI.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/herumi/mcl/issues/89#issuecomment-732105331, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARYJ2QQCE6VFT6DMGX5XMG3SRJCH3ANCNFSM4TWCYSNA .

herumi commented 3 years ago

This project already contains mcl_wrap.cxx. So I think that you can use JNI only if you set the path to com.herumi.mcl (but now I can not find it now on Android Studio).

Henzi96 commented 3 years ago

this is my make file: Where is the problem ?

po 23. 11. 2020 v 20:28 odesílatel MITSUNARI Shigeo < notifications@github.com> napsal:

This project already contains mcl_wrap.cxx https://github.com/herumi/mcl-android/blob/main/app/src/main/cpp/CMakeLists.txt#L10. So I think that you can use JNI only if you set the path to com.herumi.mcl (but now I can not find it now on Android Studio).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/herumi/mcl/issues/89#issuecomment-732376344, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARYJ2QWU2IRRQV2B2PE3SX3SRKZVHANCNFSM4TWCYSNA .

Henzi96 commented 3 years ago

https://github.com/herumi/mcl-android/blob/main/app/src/main/cpp/CMakeLists.txt#L10 https://www.codementor.io/redirect-notice?url=https%3A%2F%2Fgithub.com%2Fherumi%2Fmcl-android%2Fblob%2Fmain%2Fapp%2Fsrc%2Fmain%2Fcpp%2FCMakeLists.txt%23L10 This is compile error because there are no files

po 23. 11. 2020 v 20:35 odesílatel Jan Strakoš jan.strakos.honza@gmail.com napsal:

this is my make file: Where is the problem ?

po 23. 11. 2020 v 20:28 odesílatel MITSUNARI Shigeo < notifications@github.com> napsal:

This project already contains mcl_wrap.cxx https://github.com/herumi/mcl-android/blob/main/app/src/main/cpp/CMakeLists.txt#L10. So I think that you can use JNI only if you set the path to com.herumi.mcl (but now I can not find it now on Android Studio).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/herumi/mcl/issues/89#issuecomment-732376344, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARYJ2QWU2IRRQV2B2PE3SX3SRKZVHANCNFSM4TWCYSNA .

herumi commented 3 years ago

I've added Android.mk and Application.mk at https://github.com/herumi/mcl/tree/master/ffi/java/android/jni . It generates libmcljava.so.

Henzi96 commented 3 years ago

Works, thanks