./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 openend this issue on May 17, 2019-
gecng commented at 6:05 am on May 17, 2019: noneI use
-
gecng commented at 6:18 am on May 17, 2019: nonewhen 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: contributorI 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
configure
has a--host
option 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
0export PATH="$PATH:/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin" 1./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
0export PATH="$PATH:/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin" 1./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: noneHi @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:
0#!/bin/bash 1 2set -e 3 4if [ -z "$ANDROID_NDK" ]; then 5 echo "export the ANDROID_NDK environment variable" 6 exit 1 7fi 8 9# Only choose one of these, depending on your build machine... 10export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64 11#export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64 12 13# create links to some toolchains binaries (https://github.com/android/ndk/issues/1324) 14cd $TOOLCHAIN/bin/ 15for source in arm-linux-androideabi-* 16do 17 dest=${source/arm/armv7a} 18 ln -sf $source $dest 19done 20cd - 21 22# Set this to your minSdkVersion. 23export API=21 24 25pwd=`pwd` 26 27buildit() 28{ 29 abi=$1 30 target=$2 31 32 echo "" 33 echo "-------------------------------------------------------------------------------" 34 echo " Compiling for $abi" 35 echo "-------------------------------------------------------------------------------" 36 37 export TARGET=$target 38 39 # Configure and build. 40 export AR=$TOOLCHAIN/bin/$TARGET-ar 41 export AS=$TOOLCHAIN/bin/$TARGET-as 42 export CC=$TOOLCHAIN/bin/$TARGET$API-clang 43 export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++ 44 export LD=$TOOLCHAIN/bin/$TARGET-ld 45 export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib 46 export STRIP=$TOOLCHAIN/bin/$TARGET-strip 47 48 ./configure --prefix="$pwd/android/$abi" --host=$TARGET --disable-benchmark 49 50 make clean 51 make 52 make install 53} 54 55buildit armeabi-v7a armv7a-linux-androideabi 56buildit arm64-v8a aarch64-linux-android 57buildit x86 i686-linux-android 58buildit x86-64 x86_64-linux-android 59 60make clean 61 62echo "done. the files are in the android folder"
Save it in the repo’s root and run it:
0./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: noneYep, 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.
This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 11:15 UTC
More mirrored repositories can be found on mirror.b10c.me