-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there an option to create a shared library for Android applications? #621
Comments
when I use |
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 |
|
For reference, I can build this for example by installing Android NDK 19 and then using
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. |
Hi @real-or-random, how to build library for all Android arch? One library file for all Android platform? |
Hi, I don't think that's possible. But it's possible to build different libaries for the different platforms: Maybe we should some instructions for Android. |
Thanks for reply!
That would be great! |
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:
|
Yep, feel free |
3c15130 Improve CC_FOR_BUILD detection (Tim Ruffing) 47802a4 Restructure and tidy configure.ac (Tim Ruffing) 252c19d Ask brew for valgrind include path (Tim Ruffing) Pull request description: See individual commit messages. These are improvements in preparation of the switch to Cirrus CI. (Maybe I'll just open a PR on top of this one.) The first commit made the difference between successful build https://cirrus-ci.com/task/6740575057608704 and unsuccessful build https://cirrus-ci.com/task/4909571074424832. I've tested the second commit without cross-compilation and with cross-compilation for android (#621 (comment)) When working on the autoconf stuff, I noticed two things that I just want to write down here: - At some point we should update [build-aux/m4/ax_prog_cc_for_build.m4](https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html). This is outdated, and [there have been a lot of fixes](autoconf-archive/autoconf-archive#207) But the latest version is [broken](https://lists.gnu.org/archive/html/autoconf-archive-maintainers/2020-06/msg00002.html), so now is probably not the time. - The latest autoconf 2.70 deprecates `AC_PROG_CC_C89`. It's not needed anymore because `AC_PROG_CC` cares about testing for version support. This makes autoconf 2.70 output a warning that we should probably just ignore. We don't want to force users onto 2.70... ACKs for top commit: sipa: utACK 3c15130 jonasnick: utACK 3c15130 makes sense (with my very basic understanding of autoconf) Tree-SHA512: 595b9de316374c2213f1340cddaa22eb3190b01fa99aa6ae26e77804df41e7ecf96a09e03c28e8f8b9fd04e211e4ee2f78f1e5a7995143c84f99d2e16d4f0260
#1113 (comment) could be related. |
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. ThanksThe text was updated successfully, but these errors were encountered: