使用clang編譯openssl1.1.1d

使用clang編譯openssl1.1.1d

openssl下載地址

https://www.openssl.org/source/openssl-1.1.1d.tar.gz

ndk要使用r19以上

ndk各個 版本的下載地址

https://blog.csdn.net/u011077027/article/details/102706283

使用clang編譯 要設置ANDROID_API>=21,配置ndk的路徑,如果需要編譯其他平臺的,只需要修改architecture的值

shell腳本

#!/bin/bash
set -e
set -x

# Set directory
SCRIPTPATH=/root/openssl
export ANDROID_NDK_HOME=/root/android/android-ndk-r20
export OPENSSL_DIR=/root/openssl/openssl-1.1.1d

# Find the toolchain for your build machine
toolchains_path=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64

# Configure the OpenSSL environment, refer to NOTES.ANDROID in OPENSSL_DIR
# Set compiler clang, instead of gcc by default
CC=clang

# Add toolchains bin directory to PATH
PATH=$toolchains_path/bin:$PATH

# Set the Android API levels
ANDROID_API=21

# Set the target architecture
# Can be android-arm, android-arm64, android-x86, android-x86 etc

outdir=armeabi-v7a
architecture=android-arm

# Create the make file
cd ${OPENSSL_DIR}

make clean

./Configure ${architecture} -D__ANDROID_API__=$ANDROID_API


#./config no-ssl2 no-ssl3 no-comp no-hw no-engine \
#--openssldir=$(pwd)/../out/$ANDROID_API \
#--prefix=$(pwd)/../out/$ANDROID_API


# Build
make

# Copy the outputs
OUTPUT_INCLUDE=$SCRIPTPATH/output/include
OUTPUT_LIB=$SCRIPTPATH/output/lib/${outdir}
mkdir -p $OUTPUT_INCLUDE
mkdir -p $OUTPUT_LIB
cp -RL include/openssl $OUTPUT_INCLUDE
cp libcrypto.so $OUTPUT_LIB
cp libcrypto.a $OUTPUT_LIB
cp libssl.so $OUTPUT_LIB
cp libssl.a $OUTPUT_LIB

參數定義

安裝參數:
--openssldir=OPENSSLDIR
安裝目錄,默認是 /usr/local/ssl

--prefix=PREFIX
設置 lib include bin 目錄的前綴,默認爲 OPENSSLDIR 目錄。
--install_prefix=DESTDIR
設置安裝時以此目錄作爲"根"目錄,通常用於打包,默認爲空。

zlib
zlib-dynamic
no-zlib
使用靜態的zlib壓縮庫、使用動態的zlib壓縮庫、不使用zlib壓縮功能。

threads
no-threads
是否編譯支持多線程的庫。默認支持。

shared
no-shared
是否生成動態連接庫。

asm
no-asm
是否在編譯過程中使用匯編代碼加快編譯過程。

enable-sse2
no-sse2
啓用/禁用SSE2指令集加速。如果你的CPU支持SSE2指令集,就可以打開,否則就要關閉。

gmp
no-gmp
啓用/禁用GMP庫

rfc3779
no-rfc3779
啓用/禁用實現X509v3證書的IP地址擴展

krb5
no-krb5
啓用/禁用 Kerberos 5 支持

ssl
no-ssl

ssl2
ssl3
no-ssl2
no-ssl3

tls
no-tls
啓用/禁用 SSL(包含了SSL2/SSL3) TLS 協議支持。

dso
no-dso
啓用/禁用調用其它動態鏈接庫的功能。[提示]no-dso僅在no-shared的前提下可用。

代碼收錄

https://github.com/ddssingsong/AnyNdk

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章