This repository folder contains prebuilt libcurl binaries for Android ABIs and reproducible build scripts to (re)build libcurl yourself on Windows and Linux.
install/<BuildType>-<stripped|unstripped>/<abi>/— prebuilt outputs organized by build type and strip state (shared libs + headers)build_all.ps1— PowerShell script to build libcurl for ABIs on Windows (uses CMake + Android NDK)build_all.sh— Bash script to build libcurl for ABIs on Linux/macOS/WSLopenssl/— helper folder with OpenSSL prebuilds and build helpers (used as TLS backend)
- Purpose: provide ready-to-use
libcurl.soper ABI and a simple way to rebuild them (reproducible builds) - Supported ABIs:
arm64-v8a,armeabi-v7a,x86_64(seeinstall/)
There are two common ways to clone this repository depending on whether you want to build OpenSSL yourself or use the prebuilt OpenSSL provided as a submodule:
- If you plan to build OpenSSL yourself (you will build the
opensslfolder locally), do a normal clone:
git clone https://github.com/XDcobra/libcurl-android-prebuilt-and-buildscriptsThen build as described below.
- If you want to use the prebuilt OpenSSL libraries included as a submodule, clone with submodules so the
opensslcontent is fetched automatically:
git clone --recurse-submodules https://github.com/XDcobra/libcurl-android-prebuilt-and-buildscriptsOr, if you already cloned without --recurse-submodules, initialize submodules afterward:
git submodule update --init --recursiveNote: The build scripts expect OpenSSL files to be present under a per-build install tree such as openssl/install/<BuildType>-<stripped|unstripped>/<abi>/. You can either set OPENSSL_ANDROID_INSTALL to a BuildType-specific path (for example openssl/install/RelWithDebInfo-unstripped) or copy the ABI folders into openssl/install/<abi>/ as needed.
# set NDK path if not already
$env:ANDROID_NDK_HOME = 'C:\Users\<you>\AppData\Local\Android\Sdk\ndk\<version>'
# optionally set OpenSSL install base if you built OpenSSL into a custom location. Otherwise it defaults to /openssl/install
$env:OPENSSL_ANDROID_INSTALL = 'C:\path\to\openssl\install'
# Build Release, strip artifacts for arm64-v8a only
powershell -NoProfile -ExecutionPolicy Bypass -File build_all.ps1 -BuildType Release -Strip -ABIs @('arm64-v8a')export ANDROID_NDK_HOME=/path/to/android-ndk
export OPENSSL_ANDROID_INSTALL=/path/to/openssl/install
# Build Release, prefer stripped OpenSSL installs and build (all ABIs by default)
export BUILD_TYPE=Release
export STRIP=1
bash ./build_all.shNote: both scripts build all supported ABIs by default. To target only arm64-v8a:
- with PowerShell use the
-ABIsparameter:-ABIs @('arm64-v8a')(example shown above). - with the Bash script edit the
ABIS=(...)array near the top ofbuild_all.shand keep onlyarm64-v8a(or set up a wrapper that exports a customABISvalue before invoking the script). You can also control the build type and whether the Bash script prefersstrippedinstalls via environment variables:
# choose build type (RelWithDebInfo, Release, Debug)
export BUILD_TYPE=RelWithDebInfo
# prefer stripped OpenSSL installs (set to 1 to prefer `-stripped` folders)
export STRIP=0
bash ./build_all.shIf OPENSSL_ANDROID_INSTALL is not supplied the script will look for per-build OpenSSL installs under openssl/install/<BUILD_TYPE>-<stripped|unstripped>/<abi>/ and fall back to the legacy openssl/install/<abi>/ layout.
build_all.ps1 now supports two additional options to control build type and whether installed artifacts are stripped:
-BuildType: one ofRelWithDebInfo,Release,Debug. Default isRelease. The value is passed to CMake as-DCMAKE_BUILD_TYPE.-Strip: switch. When specified, the script will attempt to strip installed shared libraries and binaries using the NDK'sllvm-strip(orstrip) tool.
Install layout
- Outputs are stored under
install/<BuildType>-<stripLabel>/<abi>/...wherestripLabelisstrippedwhen-Stripis used andunstrippedotherwise.
Examples
# RelWithDebInfo and stripped outputs
powershell -NoProfile -ExecutionPolicy Bypass -File build_all.ps1 -NDK 'C:\path\to\android-ndk' -BuildType RelWithDebInfo -Strip
# Debug unstripped
powershell -NoProfile -ExecutionPolicy Bypass -File build_all.ps1 -NDK 'C:\path\to\android-ndk' -BuildType DebugSee build_all.ps1 for details.
If you already have unstripped outputs (for example install\RelWithDebInfo-unstripped), you can run the script in "strip-only" mode which copies the unstripped install tree to a -stripped variant and runs the NDK llvm-strip on .so and binaries.
Requirements:
- The source folder must exist:
install\<BuildType>-unstripped\. ANDROID_NDK_HOMEor-NDKmust point to an NDK withtoolchains\llvm\prebuilt\<host>.
Example (copy unstripped Release -> stripped and strip):
powershell -NoProfile -ExecutionPolicy Bypass -File build_all.ps1 -BuildType Release -OnlyStrip:$true -NDK 'C:\path\to\android-ndk'After completion the stripped outputs are available under:
install\<BuildType>-stripped\<abi>\...
- Configure CMake with the Android toolchain file and point
OPENSSL_ROOT_DIR/ libs to per-ABI OpenSSL installs. - Build with Ninja.
-- Install
libcurl.sointoinstall/<BuildType>-<stripLabel>/<abi>/lib/then copy the resultinglibcurl.so(andlibssl.so/libcrypto.soif using shared OpenSSL) into../app/src/main/jniLibs/<abi>/so your Android project can pick them up.
- Android NDK (side-by-side or bundle). Set
ANDROID_NDK_HOMEto the NDK root. Install via Android Studio or check out here - CMake (>= 3.15) and Ninja: add
C:\Program Files\CMake\binand Ninja to PATH.
choco install ninja
- Visual Studio (for general build tools) — the build scripts use CMake/Ninja and the NDK clang cross‑toolchain.
- (Optional) MSYS2 / Perl / Make if you plan to build OpenSSL with the included Windows helpers.
choco install msys2
Install/update in an MSYS2 shell:
pacman -Syu
# restart MSYS2 if it asks you to, then:
pacman -S --needed base-devel make perl git- Android NDK. Set
ANDROID_NDK_HOME. - CMake, Ninja, clang, make, perl (for OpenSSL builds).
ANDROID_NDK_HOME— path to the Android NDK (required)OPENSSL_ANDROID_INSTALLorOPENSSL_ROOT_DIR— path to the OpenSSL install base. If you built OpenSSL with build helpers in this repo the outputs are organized underopenssl/install/<BuildType>-<stripped|unstripped>/so point this variable to the desired build-type folder (e.g.openssl/install/RelWithDebInfo-unstripped).BUILD_TYPE(bash): controls-DCMAKE_BUILD_TYPEwhen runningbuild_all.sh(default:Release).STRIP(bash): if set to1, the bash script will prefer-strippedOpenSSL installs when resolving the OpenSSL ABI folder (default:0).CURL_VERSION(optional) — override curl version the script downloads
- The build scripts will prefer per-build OpenSSL install folders:
openssl/install/<BuildType>-<stripped|unstripped>/<abi>/libwith headers under.../<abi>/include. - If those are not present, the scripts will fall back to the legacy layout
openssl/install/<abi>/libandopenssl/install/<abi>/include. - This repository includes a submodule containing prebuilt OpenSSL libraries for the supported ABIs. If you want to build your own OpenSSL libraries, see openssl-android-prebuilt-and-buildscripts.
- If CMake fails to find OpenSSL, make sure
OPENSSL_ROOT_DIRand theinclude/libpaths exist for the ABI you're building. - On Windows prefer running the build in a Developer PowerShell with NDK/Toolchain in PATH, or use WSL/Git-Bash for the OpenSSL build steps.
- This folder contains OpenSSL libraries which are licensed under the OpenSSL license. Keep
LICENSE/LICENSE.txtwith the distributed artifacts.