| 223 | == OpenSSL Support == |
| 224 | |
| 225 | 1. Build OpenSSL (tested with OpenSSL 1.0.2a) for Android. The instruction provided here is specifically for arm64. For other architectures, modify accordingly. Please visit [http://stackoverflow.com/questions/11929773/compiling-the-latest-openssl-for-android this page] for reference and some examples. Note: change the NDK path below. |
| 226 | {{{ |
| 227 | cd openssl-1.0.2a |
| 228 | |
| 229 | export NDK=[your_android_ndk_path]/android-ndk-r10d |
| 230 | |
| 231 | $NDK/build/tools/make-standalone-toolchain.sh --platform=android-21 --toolchain=aarch64-linux-android-4.9 --install-dir=`pwd`/android-toolchain-arm64 |
| 232 | export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm64/bin |
| 233 | export TOOL=aarch64-linux-android |
| 234 | export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL} |
| 235 | export CC=$NDK_TOOLCHAIN_BASENAME-gcc |
| 236 | export CXX=$NDK_TOOLCHAIN_BASENAME-g++ |
| 237 | export LINK=${CXX} |
| 238 | export LD=$NDK_TOOLCHAIN_BASENAME-ld |
| 239 | export AR=$NDK_TOOLCHAIN_BASENAME-ar |
| 240 | export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib |
| 241 | export STRIP=$NDK_TOOLCHAIN_BASENAME-strip |
| 242 | export ARCH_FLAGS= |
| 243 | export ARCH_LINK= |
| 244 | export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 " |
| 245 | export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions " |
| 246 | export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 " |
| 247 | export LDFLAGS=" ${ARCH_LINK} " |
| 248 | |
| 249 | ./Configure android |
| 250 | make |
| 251 | }}} |
| 252 | Then copy the libraries into libs folder: |
| 253 | {{{ |
| 254 | mkdir libs |
| 255 | cp lib*.a libs/ |
| 256 | }}} |
| 257 | 1. Specify OpenSSL location when running {{{configure-android}}}, for example (with Bash): (change the openssl path folder) |
| 258 | {{{ |
| 259 | TARGET_ABI=arm64-v8a ./configure-android --use-ndk-cflags --with-ssl=[your_openssl_path]/openssl-1.0.2a |
| 260 | }}} |
| 261 | And check that OpenSSL is detected by the configure script: |
| 262 | {{{ |
| 263 | ... |
| 264 | checking for OpenSSL installations.. |
| 265 | checking openssl/ssl.h usability... yes |
| 266 | checking openssl/ssl.h presence... no |
| 267 | aconfigure: WARNING: openssl/ssl.h: accepted by the compiler, rejected by the preprocessor! |
| 268 | aconfigure: WARNING: openssl/ssl.h: proceeding with the compiler's result |
| 269 | checking for openssl/ssl.h... yes |
| 270 | checking for ERR_load_BIO_strings in -lcrypto... yes |
| 271 | checking for SSL_library_init in -lssl... yes |
| 272 | OpenSSL library found, SSL support enabled |
| 273 | ... |
| 274 | }}} |
| 275 | 1. Build the libraries: |
| 276 | {{{ |
| 277 | make dep && make |
| 278 | }}} |
| 279 | If you encounter linking errors, you need to add this in user.mak: |
| 280 | {{{ |
| 281 | export LIBS += "-ldl -lz" |
| 282 | }}} |