Skip to content

OpenSSL static and dynamic libraries build scripts. Could be used in Qt Android Projects.

License

Notifications You must be signed in to change notification settings

swex/openssl-android-build

 
 

Repository files navigation

openssl-android-build

Working build scripts for OpenSSL libcrypto and libssl static and dynamic libraries primarily for using on Android. Mac, and Linux build script are kept and updated as well. Windows version removed from current repo, look to original one for the instructions.

This repo took best workable ideas from ekke/android-openssl-qt and couchbaselabs/couchbase-lite-libcrypto repos - many thanks to their authors! More ideas about these scripts creation could be found there. Resulting scripts successfully do all for you from downloading and extracting openssl and generating libs for x86, armeabi-v7a, arm64-v8a architectures.

Default OpenSSL version is 1.0.2o as currently used in Qt Creator.

How to rebuild the binaries

1. Setup the project

$ git clone https://github.com/akontsevich/openssl-android-build.git
$ export OPENSSL_VERSION="openssl-1.0.2o"

2. Generate include headers

Run the following command on a Mac

$ ./generate-headers-mac.sh

or Linux machine:

$ ./generate-headers.sh

The headers will be output at libs/include.

3. Build the binaries for each platform

3.1 Android

Requirements

  1. Download Android NDK

Note. You need to download FULL NDK version as Android Studio ships reduced version which may cause build failure.

  1. Mac OSX or Linux Machine

Common Build Steps

  1. Make sure that you have the ANDROID_NDK_HOME variable defined. For example,
#.bashrc:
export ANDROID_NDK_HOME=~/Android/android-ndk-r10e

or

 #.bashrc:
 export ANDROID_NDK_HOME=~/Android/android-ndk-r18b

Build Steps with GCC

  1. Run the build script. The binaries will be output at libs/android
$ ./build-android.sh

Build Steps with clang

  1. Run the build script. The binaries will be output at libs/android/clang

Note. More modern NDK version recommended to use there:

export ANDROID_NDK_HOME=~/Android/android-ndk-r18b
$ ./build-android-clang.sh

3.2 WebAssembly

Requirements

  1. Downdload and install Emscripten: http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
  2. Enter into emsdk dir and activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh

Build Steps with Emscripten

  1. Run the build script. The binaries will be output at libs/wasm
$ ./build-emscripten.sh

3.3 OSX and iOS

Requirements

  1. XCode
  2. makedepend (if you don't have one)
$ homebrew install makedepend

or

$ brew install makedepend

Build Steps

Run the build script. The binaries will be output at libs/osx and libs/ios. The osx and ios binaries are universal libraries.

$ ./build-osx-ios.sh

3.4 Linux

Requirements

  1. GCC
  2. makedepend (if you don't have one) On Ubuntu:
$ sudo apt-get install xutils-dev

In openSUSE:

$ sudo zypper in makedepend

Build Steps

Run the build script. The binaries will be output at libs/linux.

$ ./build-linux.sh

4. Qt project file modifications

Modify .pro file in a Qt project: insert this line into your .pro:

include(android-build.pri)

Assume build libraries and headers copied to ./3rdparty dir or your source tree. Following structure considers we build clang library version:

$$PWD/3rdparty
    └── include
        └── openssl
            └── *.h
    └── libs/llvm
            ├── arm64-v8a
            │   ├── libcrypto.a
            │   ├── libcrypto.so
            │   ├── libssl.a
            │   └── libssl.so
            ├── arch-armeabi-v7a
            │   ├── libcrypto.a
            │   ├── libcrypto.so
            │   ├── libssl.a
            │   └── libssl.so
            └── arch-x86
                ├── libcrypto.a
                ├── libcrypto.so
                ├── libssl.a
                └── libssl.so

.pri file content

android {
INCLUDEPATH += $$absolute_path($$PWD/3rdparty/include)

equals(ANDROID_TARGET_ARCH, arm64-v8a) {
    LIBPATH = $$absolute_path($$PWD/3rdparty/libs/llvm/arm64-v8a)
}

equals(ANDROID_TARGET_ARCH, armeabi-v7a) {
    LIBPATH = $$absolute_path($$PWD/3rdparty/libs/llvm/armeabi-v7a)
}

LIBS += \
    -L$$LIBPATH \
    -lssl -lcrypto

ANDROID_EXTRA_LIBS += \
    $$LIBPATH/libssl.so \
    $$LIBPATH/libcrypto.so
}

About

OpenSSL static and dynamic libraries build scripts. Could be used in Qt Android Projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%