必威体育Betway必威体育官网
当前位置:首页 > IT技术

移植Open SSL库(一)

时间:2019-10-02 22:41:05来源:IT技术作者:seo实验室小编阅读:76次「手机版」
 

open ssl

1、下载工程

https://www.openssl.org/source/

下载最新版的openssl-1.1.1-pre5

2、打开NOTES.Android

加压后进入根目录,可以看到

configuration

-------------

Android is naturally cross-compiled target and you can't use ./config.

You have to use ./configure and name your target explicitly; there are

android-arm, android-arm64, android-mips, android-mip64, android-x86

and android-x86_64. Do not pass --cross-compile-prefix (as you might

be tempted), as it will be "calculated" automatically based on chosen

platform. Though you still need to know the prefix to extend your PATH,

in order to invoke $(CROSS_COMPILE)gcc and company. (Configure will fail

and give you a hint if you get it wrong.) Apart from PATH adjustment

you need to set ANDROID_NDK environment to point at NDK directory

as /some/where/android-ndk-<ver>. NDK customarily supports multiple

Android API levels, e.g. android-14, android-21, etc. By default latest 

one available is chosen. If you need to target older platform, pass

additional -D__ANDROID_API__=N to Configure. N is numeric value of the

target platform version. For example, to compile for ICS on ARM with

NDK 10d:

ANDROID_NDK=/some/where/android-ndk-10d

PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/bin:$PATH

./Configure android-arm -D__ANDROID_API__=14

这样一段话,根据这句话,写编译脚本build-android.sh如下

cd /home/yong/Desktop/test-android-openssl-001/openssl-1.1.1-pre5
rm -rf ./android
mkdir ./android
export ANDROID_NDK=/home/yong/Downloads/android-ndk-r16b
export PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
./Configure android-arm -D__ANDROID_API__=23 --prefix=/home/yong/Desktop/test-android-openssl-001/openssl-1.1.1-pre5/android
make && make install

3、执行编译

sh build-android.sh

再到根目录/android下,即可看到编译结果

* 编译脚本改进

#armeabi armeabi-v7a armeabi-v7a-hard arm64-v8a mips mips64 x86 x86_64
export ARCH=arm

cd /home/yong/Desktop/test-android-openssl-001/openssl-1.1.1-pre5
make clean
rm -rf ./android-$ARCH
mkdir ./android-$ARCH
export ANDROID_NDK=/home/yong/Downloads/android-ndk-r16b
export PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
./Configure android-$ARCH -D__ANDROID_API__=23 --prefix=/home/yong/Desktop/test-android-openssl-001/openssl-1.1.1-pre5/android-$ARCH
make && make install

*编译脚本改进

其中ARCH_NAME的备选值可以从NOTES.ANDROID文件中找到。

func_cmp(){
	cd /home/yong/Desktop/test-android-openssl-001/openssl-1.1.1-pre5
	make clean
	rm -rf ./android-$ARCH
	mkdir ./android-$ARCH
	export ANDROID_NDK=/home/yong/Downloads/android-ndk-r16b
	export PATH=$ANDROID_NDK/toolchains/$TOOL_CHAIN/prebuilt/linux-x86_64/bin:$PATH
	./Configure $ARCH_NAME -D__ANDROID_API__=23 --prefix=/home/yong/Desktop/test-android-openssl-001/openssl-1.1.1-pre5/android-$ARCH
	make && make install
}

for ARCH in armeabi-v7a armeabi arm64-v8a x86 x86_64 mips mips64
do
	echo $ARCH
	if [ "$ARCH" = "armeabi-v7a" ]; then
		ARCH_NAME=android-arm
		TOOL_CHAIN=arm-linux-androideabi-4.9
	fi
	if [ "$ARCH" = "armeabi" ]; then
		ARCH_NAME=android-arm
		TOOL_CHAIN=arm-linux-androideabi-4.9
	fi
	if [ "$ARCH" = "arm64-v8a" ]; then
		ARCH_NAME=android-arm64
		TOOL_CHAIN=aarch64-linux-android-4.9
	fi
	if [ "$ARCH" = "mips" ]; then
		ARCH_NAME=android-mips
		TOOL_CHAIN=mipsel-linux-android-4.9
	fi
	if [ "$ARCH" = "mips64" ]; then
		ARCH_NAME=android-mip64
		TOOL_CHAIN=mips64el-linux-android-4.9
	fi
	if [ "$ARCH" = "x86" ]; then
		ARCH_NAME=android-x86
		TOOL_CHAIN=x86-4.9
	fi
	if [ "$ARCH" = "x86_64" ]; then
		ARCH_NAME=android-x86_64
		TOOL_CHAIN=x86_64-4.9
	fi
	echo $TOOL_CHAIN
	func_cmp
done

相关阅读

数据库查询时报错:invalid identifier

oracle数据库新建了一个表查询时报错:invalid identifier 百度之后解决方法:在要查的属性上加上双引号即可。如下: 有人遇到这种问

git大仓库拆成若干小仓库

我们要把每个项目变成独立的git仓库,并且保留commit记录。 根据1 项目原始文件: MyHugeRepo/ .git/ DIR_A/ DIR_B/ DIR_C/

优衣库视频炒作,你还在无节操的要种子吗?

朋友圈彻底被优衣库视频刷爆了,优衣库视频几乎攻陷所有的城池。如果到目前为止,你还没有看到或者听说过优衣库的视频,可能有两种情况

数据库的四种连接方式 关系型和非关系型区别

内连接 内连接  ---拼接查询结果 内部有联系,使用内连接 格式: [inner] join ----inner可省 结果: 从左表中取出每一条记录,去右表

access数据库教程

笔者在大学时用过Dreamweaver做过静态和动态的站点,当时用的数据库就是access,很惭愧当时笔者是一个很菜很菜的菜鸟,很多设计还需要

分享到:

栏目导航

推荐阅读

热门阅读