[Interest] Android OpenSSL EVP

Jérôme Godbout godboutj at amotus.ca
Thu Mar 25 20:04:50 CET 2021


Hi,
anyone have use OpenSSL EVP interface under Android? I manage to make it work under MacOS, Windows, Linux, but under Android I can add the OpenSSL lib, I compiled them for each arch (x86, x86_64, armv7, armv8) and I add all the libs with (I use Qt 5.15.2 only for this):

INCLUDEPATH+= $$OPEN_SSL_PATH/include
ANDROID_EXTRA_LIBS += \
        $$OPEN_SSL_PATH/Android/armeabi-v7a/libcrypto_1_1.so \
        $$OPEN_SSL_PATH/Android/armeabi-v7a/libssl_1_1.so \
        $$OPEN_SSL_PATH/Android/arm64-v8a/libcrypto_1_1.so \
        $$OPEN_SSL_PATH/Android/arm64-v8a/libssl_1_1.so \
        $$OPEN_SSL_PATH/Android/x86/libcrypto_1_1.so \
        $$OPEN_SSL_PATH/Android/x86/libssl_1_1.so \
        $$OPEN_SSL_PATH/Android/x86_64/libcrypto_1_1.so \
        $$OPEN_SSL_PATH/Android/x86_64/libssl_1_1.so

This work to use OpenSSL, but I cannot use the EVP, header are added, it fail at link time of the Qt application.  I’m not even sure what Qt does with ANDROID_EXTRA_LIBS and how can the C++ code can link against the current arch lib?
Any way to do this that will work on each arch? This is how I compiled my libs btw (under MacOS):

#!/bin/bashVERSION=1.1.1j
ANDROID_SDK_HOME=/Users/Shared/AndroidSDK
export ANDROID_NDK_HOME=$ANDROID_SDK_HOME/ndk/21.1.6352462
if [ ! -f "openssl-$VERSION.tar.gz" ]; then
    wget https://www.openssl.org/source/openssl-$VERSION.tar.gz
fi
for arch in "armeabi-v7a" "arm64-v8a" "x86" "x86_64"
do
    pushd .
    rm -fr $arch
    mkdir $arch
    rm -fr openssl-$VERSION
    tar xf openssl-$VERSION.tar.gz
    cd openssl-$VERSION    case $arch in
        armeabi-v7a)
            ANDROID_API=16
            CONFIG_ARCH="arm"
            ;;
        x86)
            ANDROID_API=16
            CONFIG_ARCH="x86"
            ;;
        arm64-v8a)
            ANDROID_API=21
            CONFIG_ARCH="arm64"
            ;;
        x86_64)
            ANDROID_API=21
            CONFIG_ARCH="x86_64"
            ;;
    esac
    ANDROID_TOOLCHAIN=""
    for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86"
    do
        if [ -d "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$host/bin" ]; then
            ANDROID_TOOLCHAIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$host/bin"
            break
        fi
    done    export PATH="$ANDROID_TOOLCHAIN":"$PATH"    ./Configure shared android-${CONFIG_ARCH} -D__ANDROID_API__=${ANDROID_API} || exit 1
    make depend    make -j$(nproc) SHLIB_VERSION_NUMBER= SHLIB_EXT=_1_1.so build_libs || exit 1
    llvm-strip --strip-all libcrypto_1_1.so
    llvm-strip --strip-all libssl_1_1.so
    cp libcrypto_1_1.so ../$arch || exit 1
    cp libssl_1_1.so ../$arch || exit 1
    popd
done



Jérôme Godbout, B. Ing.

Software / Firmware Team Lead
O: (418) 682-3636 ext.: 114
C: (581) 777-0050
godboutj at dimonoff.com<mailto:godboutj at dimonoff.com>
[signature_868826015]<https://www.dimonoff.com/>
dimonoff.com<https://www.dimonoff.com/>
1015 Avenue Wilfrid-Pelletier,
Québec, QC G1W 0C4, 4e étage

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210325/9b14c2a4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 13927 bytes
Desc: image001.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210325/9b14c2a4/attachment.png>


More information about the Interest mailing list