Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Android OpenSSL support for Qt
OpenSSL scripts and binaries for Android (useful for Qt Android apps)
OpenSSL scripts and binaries - supports Qt for Android apps.

In this repo you can find the prebuilt OpenSSL libs for Android, a QMake include project `.pri` file that can be used integrated with Qt projects, and a `.cmake` file for CMake based projects.

Expand Down Expand Up @@ -50,10 +50,10 @@ endif()

## Build Script

The build script `build_ssl.sh` can be used to rebuild the OpenSSL libraries. Since specific
versions might depend or work better with specific NDK versions, the OpenSSL/NDK version
combinations are defined in the script. Before running the script, check that the NDK paths
are correct for your environment.
You may use `build_ssl.sh` to rebuild OpenSSL libraries. OpenSSL/NDK version
pairs are predefined in the script to ensure compatibility with specific Qt
versions. Make sure the NDK paths and versions match your setup before running
it.

### Build Prerequisites

Expand Down
22 changes: 13 additions & 9 deletions build_ssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,15 @@ EOF
;;
esac

echo "Configuring OpenSSL $ssl_version with NDK $ndk on ABI $arch"
config_params=( "${build_type}" "shared" "android-${arch}"
"-U__ANDROID_API__" "-D__ANDROID_API__=${ANDROID_API}" )
echo "Configuring OpenSSL $ssl_version with NDK $ndk"
if [ "$arch" = "arm64" -o "$arch" = "x86_64" ]; then
if [ "${ndk:0:2}" -ge 25 ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't really need to check for this, and the full LDFLAGS to support even older NDKs we could use

-Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384

and in general since OpenSSL 3 is the one we want to enable 16kb for, we need to do it for that only, and explicitly instead of implicitly here with the check for NDK 25.

And to do that explicitly, I suggest these edits to this commit:

From 5d216493a92c8e786278df41710f7f6ac1c69eb7 Mon Sep 17 00:00:00 2001
From: Assam Boudjelthia <assam.boudjelthia@qt.io>
Date: Wed, 1 Oct 2025 12:42:07 +0300
Subject: [PATCH] Support 16kb page sizes for OpenSSL 3

---
 build_ssl.sh | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/build_ssl.sh b/build_ssl.sh
index 238a630..21c8390 100755
--- a/build_ssl.sh
+++ b/build_ssl.sh
@@ -117,6 +117,7 @@ configure_ssl() {
         fi
     done
 
+    version_config_params=
     case $ssl_version in
     1.1.*)
         ANDROID_API=21
@@ -137,6 +138,9 @@ EOF
         ;;
     3.*)
         ANDROID_API=23
+        if [ "$arch" = "arm64" -o "$arch" = "x86_64" ]; then
+            version_config_params=( "-Wl,-z,max-page-size=16384" "-Wl,-z,common-page-size=16384" )
+        fi
         # use suffix _3.so with OpenSSL 3.1.x (Qt 6.5.0 and above)
         patch -p0 <<EOF
 --- Configurations/15-android.conf
@@ -153,11 +157,21 @@ EOF
         ;;
     esac
 
-    config_params=( "${build_type}" "shared" "android-${arch}"
-                    "-U__ANDROID_API__" "-D__ANDROID_API__=${ANDROID_API}" )
-    echo "Configuring OpenSSL $ssl_version with NDK $ndk"
-    echo "Configure parameters: ${config_params[@]}"
+    echo "Configuring OpenSSL $ssl_version for ABI $arch with NDK $ndk"
+    config_params=
+
+    if [ -n "$build_type" ]; then
+        config_params+=( "${build_type}" )
+    fi
 
+    config_params+=( "shared" "android-${arch}" "-U__ANDROID_API__"
+                     "-D__ANDROID_API__=${ANDROID_API}" )
+
+    if [ -n "${version_config_params[*]}" ]; then
+        config_params+=( "${version_config_params[@]}" )
+    fi
+
+    echo "Configure parameters: ${config_params[@]}"
     ./Configure "${config_params[@]}" 2>&1 1>${log_file} | tee -a ${log_file} || exit 1
     make depend
 }
-- 
2.50.1 (Apple Git-155)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the check for ABI's also the 32-bit ABI's got binaries re-build as 16KB page sized. I checked that with helper script. Do we really want that? It might not make harm though.

16KB checking in Qt for Android and the instructions from Google mention NDK as the factor, not OpenSSL version. I would prefer to keep the NDK there. Like discussed it is a bit matter of taste in case of Qt as the supported Qt 6 versions only support NDK25 and higher and also OpenSSL 3.

Copy link
Collaborator

@Issam-b Issam-b Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I don't see how this code above script diff would produce 16kb aligned 32-bit libs, there's an explicit check the for arm64 and x64, and locally I'm getting the expected result as well.

echo "Configuring OpenSSL to 16KB page sizes"
config_params+=("LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=16384"")
fi
fi
echo "Configure parameters: ${config_params[@]}"

./Configure "${config_params[@]}" 2>&1 1>${log_file} | tee -a ${log_file} || exit 1
Expand Down Expand Up @@ -220,20 +226,18 @@ for build_type in "${build_types[@]}"; do
rm -fr "$output_dir"
mkdir -p "$output_dir" || exit 1

build_ssl ${log_file}
strip_libs
copy_build_artefacts ${output_dir}

# Copy the include dir only once since since it's the same for all abis
if [ ! -d "$output_dir/../include" ]; then
cp -a include "$output_dir/../" || exit 1

# Clean include folder
find "$output_dir/../" -name "*.in" -delete
find "$output_dir/../" -name "*.def" -delete
find "$output_dir/../" -name "*.in" -print -delete
find "$output_dir/../" -name "*.def" -print -delete
fi

build_ssl ${log_file}
strip_libs
copy_build_artefacts ${output_dir}


popd
done
popd
Expand Down