diff --git a/README.md b/README.md index f8e79cf..46a3494 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # android_openssl OpenSSL scripts and bins for Android (useful for Qt on Android apps) + +In this repo you can find prebuilt openssl libs for Android and a qmake script diff --git a/aarch64/libcrypto.so b/aarch64/libcrypto.so new file mode 100755 index 0000000..b0a2f94 Binary files /dev/null and b/aarch64/libcrypto.so differ diff --git a/aarch64/libssl.so b/aarch64/libssl.so new file mode 100755 index 0000000..b2df270 Binary files /dev/null and b/aarch64/libssl.so differ diff --git a/arm/libcrypto.so b/arm/libcrypto.so new file mode 100755 index 0000000..5bd46ca Binary files /dev/null and b/arm/libcrypto.so differ diff --git a/arm/libssl.so b/arm/libssl.so new file mode 100755 index 0000000..77c85dc Binary files /dev/null and b/arm/libssl.so differ diff --git a/build_ssl.sh b/build_ssl.sh new file mode 100755 index 0000000..d56b9fe --- /dev/null +++ b/build_ssl.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +VERSION=1.0.2q +export ANDROID_NDK_ROOT=~/android/android-ndk-r10e +export ANDROID_API=android-21 + +if [ ! -f "openssl-$VERSION.tar.gz" ]; then + wget https://www.openssl.org/source/openssl-$VERSION.tar.gz +fi + +for arch in "x86" "aarch64" "arm" +do + rm -fr $arch + mkdir $arch + rm -fr openssl-$VERSION + tar xfa openssl-$VERSION.tar.gz + cd openssl-$VERSION + + case $arch in + arm) + export ANDROID_PLATFORM=arch-arm + export ANDROID_EABI="arm-linux-androideabi-4.9" + export CROSS_COMPILE="arm-linux-androideabi-" + CONF_PARAM=android + ;; + aarch64) + export ANDROID_PLATFORM=arch-arm64 + export ANDROID_EABI="aarch64-linux-android-4.9" + export CROSS_COMPILE="aarch64-linux-android-" + CONF_PARAM=android + ;; + x86) + export ANDROID_PLATFORM=arch-x86 + export ANDROID_EABI="x86-4.9" + export CROSS_COMPILE="i686-linux-android-" + CONF_PARAM=android-x86 + ;; +# x86_64) +# export ANDROID_EABI="x86_64-4.9" +# export ANDROID_ARCH=arch-x86_64 +# export ARCH=x86_64 +# export CROSS_COMPILE=x86_64-linux-android- +# CONF_PARAM="linux-generic64 no-asm -m64 -no-ssl2 -no-ssl3 -no-comp -no-hw --cross-compile-prefix=$CROSS_COMPILE" +# ;; + esac + export SYSTEM=android + export ANDROID_SYSROOT=$ANDROID_NDK_ROOT/platforms/$ANDROID_API/$ANDROID_PLATFORM + export ANDROID_DEV=$ANDROID_SYSROOT/usr + export CFLAGS="--sysroot=$ANDROID_SYSROOT" + export CPPFLAGS="--sysroot=$ANDROID_SYSROOT" + export CXXFLAGS="--sysroot=$ANDROID_SYSROOT" + + ANDROID_TOOLCHAIN="" + for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86" + do + if [ -d "$ANDROID_NDK_ROOT/toolchains/$ANDROID_EABI/prebuilt/$host/bin" ]; then + ANDROID_TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/$ANDROID_EABI/prebuilt/$host/bin" + break + fi + done + + export PATH="$ANDROID_TOOLCHAIN":"$PATH" + + ./Configure shared $CONF_PARAM || exit 1 + make depend + make -j$(nproc) CALC_VERSIONS="SHLIB_COMPAT=; SHLIB_SOVER=" build_libs || exit 1 + ${CROSS_COMPILE}strip -s libcrypto.so + ${CROSS_COMPILE}strip -s libssl.so + cp libcrypto.so ../$arch + cp libssl.so ../$arch + cd .. +done diff --git a/openssl.pri b/openssl.pri new file mode 100644 index 0000000..6bfbd68 --- /dev/null +++ b/openssl.pri @@ -0,0 +1,17 @@ +contains(ANDROID_TARGET_ARCH,armeabi-v7a) { + ANDROID_EXTRA_LIBS += \ + $$PWD/arm/libcrypto.so \ + $$PWD/arm/libssl.so +} + +contains(ANDROID_TARGET_ARCH,arm64-v8a) { + ANDROID_EXTRA_LIBS += \ + $$PWD/aarch64/libcrypto.so \ + $$PWD/aarch64/libssl.so +} + +contains(ANDROID_TARGET_ARCH,x86) { + ANDROID_EXTRA_LIBS += \ + $$PWD/x86/libcrypto.so \ + $$PWD/x86/libssl.so +} diff --git a/x86/libcrypto.so b/x86/libcrypto.so new file mode 100755 index 0000000..ac5cc35 Binary files /dev/null and b/x86/libcrypto.so differ diff --git a/x86/libssl.so b/x86/libssl.so new file mode 100755 index 0000000..59b2a77 Binary files /dev/null and b/x86/libssl.so differ