I use ./configure --enable-jni --enable-experimental --enable-module-schnorr --enable-module-ecdh and get one secp256k1.so files.but there are many different CPU architectures in android like armeabi ,rmeabi-v7a,arm64-v8a ,x86 . Could you please tell me how should I do to create .so files for different CPU architectures. Thanks
Is there an option to create a shared library for Android applications? #621
issue gecng opened this issue on May 17, 2019-
gecng commented at 6:05 AM on May 17, 2019: none
-
gecng commented at 6:18 AM on May 17, 2019: none
when I use
System.loadLibrary("javasecp256k1"), it throws exception java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.wallet.locker-Gpfu8hdv5zMz363H3eJC8Q==/lib/arm/libjavasecp256k1.so" is 64-bit instead of 32-bit. -
sipa commented at 8:11 PM on May 18, 2019: contributor
I don't much about Android, but generally I would expect you need a separate build/.so per architecture, and then ship the right one for the used architecture.
-
gecng commented at 3:08 AM on May 19, 2019: none
I don't much about Android, but generally I would expect you need a separate build/.so per architecture, and then ship the right one for the used architecture.
yes,I really need a separate build/.so per architecture, but I don't know the way to build it
-
real-or-random commented at 6:39 AM on May 20, 2019: contributor
configurehas a--hostoption for cross compilation. -
real-or-random commented at 4:40 PM on May 24, 2019: contributor
For reference, I can build this for example by installing Android NDK 19 and then using
export PATH="$PATH:/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin" ./configure --enable-ecmult-static-precomputation --enable-experimental --with-bignum=no --with-asm=arm --host=arm-linux-androideabi CC=armv7a-linux-androideabi21-clang CFLAGS="-mthumb -march=armv7-a" CCASFLAGS="-Wa,-mthumb -Wa,-march=armv7-a"See https://developer.android.com/ndk/guides/standalone_toolchain for more information, e.g., the right flags for other targets.
-
gecng commented at 5:08 AM on May 27, 2019: none
For reference, I can build this for example by installing Android NDK 19 and then using
export PATH="$PATH:/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin" ./configure --enable-ecmult-static-precomputation --enable-experimental --with-bignum=no --with-asm=arm --host=arm-linux-androideabi CC=armv7a-linux-androideabi21-clang CFLAGS="-mthumb -march=armv7-a" CCASFLAGS="-Wa,-mthumb -Wa,-march=armv7-a"See https://developer.android.com/ndk/guides/standalone_toolchain for more information, e.g., the right flags for other targets.
thank you very much , i use this way and has solved my problem.
- gecng closed this on May 27, 2019
- real-or-random cross-referenced this on Dec 5, 2019 from issue travis: Add some arm builds by MarcoFalke
-
strongpower commented at 3:13 AM on April 3, 2020: none
Hi @real-or-random, how to build library for all Android arch? One library file for all Android platform?
-
real-or-random commented at 8:06 AM on April 3, 2020: contributor
Hi, I don't think that's possible. But it's possible to build different libaries for the different platforms: https://developer.android.com/ndk/guides/other_build_systems#autoconf And then I'm sure there's also a way to ship all of these builds in different builds of your app but I have no idea how this works.
Maybe we should some instructions for Android.
-
strongpower commented at 10:02 AM on April 3, 2020: none
Thanks for reply!
Maybe we should some instructions for Android.
That would be great!
- real-or-random cross-referenced this on Apr 6, 2020 from issue Add better build documentation by gmaxwell
-
kroggen commented at 4:29 PM on November 20, 2020: none
I use this script to build for Android:
#!/bin/bash set -e if [ -z "$ANDROID_NDK" ]; then echo "export the ANDROID_NDK environment variable" exit 1 fi # Only choose one of these, depending on your build machine... export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64 #export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64 # create links to some toolchains binaries (https://github.com/android/ndk/issues/1324) cd $TOOLCHAIN/bin/ for source in arm-linux-androideabi-* do dest=${source/arm/armv7a} ln -sf $source $dest done cd - # Set this to your minSdkVersion. export API=21 pwd=`pwd` buildit() { abi=$1 target=$2 echo "" echo "-------------------------------------------------------------------------------" echo " Compiling for $abi" echo "-------------------------------------------------------------------------------" export TARGET=$target # Configure and build. export AR=$TOOLCHAIN/bin/$TARGET-ar export AS=$TOOLCHAIN/bin/$TARGET-as export CC=$TOOLCHAIN/bin/$TARGET$API-clang export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++ export LD=$TOOLCHAIN/bin/$TARGET-ld export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib export STRIP=$TOOLCHAIN/bin/$TARGET-strip ./configure --prefix="$pwd/android/$abi" --host=$TARGET --disable-benchmark make clean make make install } buildit armeabi-v7a armv7a-linux-androideabi buildit arm64-v8a aarch64-linux-android buildit x86 i686-linux-android buildit x86-64 x86_64-linux-android make clean echo "done. the files are in the android folder"Save it in the repo's root and run it:
./make-android -
real-or-random commented at 9:00 AM on November 23, 2020: contributor
-
kroggen commented at 3:44 PM on November 23, 2020: none
Yep, feel free
- real-or-random cross-referenced this on Jan 2, 2021 from issue Autoconf improvements by real-or-random
- real-or-random referenced this in commit f2d9aeae6d on Jan 12, 2021
- real-or-random cross-referenced this on May 29, 2022 from issue How to compile Secp256K1 .a static library for different architectures by BatterMan-Li
-
hebasto commented at 8:04 PM on June 28, 2022: member
#1113 (comment) could be related.