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

http://www.openssl.org/source/license.html

#

See http://wiki.openssl.org/index.php/FIPS_Library_and_Android

and http://wiki.openssl.org/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

相关文章
|
5天前
|
Ubuntu 测试技术 网络安全
Ubuntu系统下部署flatpress轻量级博客系统
【10月更文挑战第3天】Ubuntu系统下部署flatpress轻量级博客系统
23 2
Ubuntu系统下部署flatpress轻量级博客系统
|
6天前
|
IDE Android开发 iOS开发
探索安卓与iOS系统的技术差异:开发者的视角
本文深入分析了安卓(Android)与苹果iOS两大移动操作系统在技术架构、开发环境、用户体验和市场策略方面的主要差异。通过对比这两种系统的不同特点,旨在为移动应用开发者提供有价值的见解,帮助他们在不同平台上做出更明智的开发决策。
|
6天前
|
编译器 Android开发
配置环境变量,使CMakeLists.txt可直接使用Android NDK工具链编译项目
配置环境变量,使CMakeLists.txt可直接使用Android NDK工具链编译项目
|
24天前
|
监控 Android开发 iOS开发
深入探索安卓与iOS的系统架构差异:理解两大移动平台的技术根基在移动技术日新月异的今天,安卓和iOS作为市场上最为流行的两个操作系统,各自拥有独特的技术特性和庞大的用户基础。本文将深入探讨这两个平台的系统架构差异,揭示它们如何支撑起各自的生态系统,并影响着全球数亿用户的使用体验。
本文通过对比分析安卓和iOS的系统架构,揭示了这两个平台在设计理念、安全性、用户体验和技术生态上的根本区别。不同于常规的技术综述,本文以深入浅出的方式,带领读者理解这些差异是如何影响应用开发、用户选择和市场趋势的。通过梳理历史脉络和未来展望,本文旨在为开发者、用户以及行业分析师提供有价值的见解,帮助大家更好地把握移动技术发展的脉络。
49 6
|
20天前
|
Dart 开发工具 Android开发
在 Android 系统上搭建 Flutter 环境的具体步骤是什么?
在 Android 系统上搭建 Flutter 环境的具体步骤是什么?
|
6天前
|
Ubuntu jenkins 持续交付
Ubuntu系统 用docker安装jenkins
Ubuntu系统 用docker安装jenkins
|
1月前
|
存储 Prometheus 监控
在Ubuntu系统上安装与配置Prometheus的步骤
通过以上步骤,您应该已经成功在Ubuntu系统上安装并配置了Prometheus。您现在可以开始使用Prometheus收集和分析您的系统和应用程序的指标数据了。
60 1
|
1月前
|
监控 Ubuntu API
Python脚本监控Ubuntu系统进程内存的实现方式
通过这种方法,我们可以很容易地监控Ubuntu系统中进程的内存使用情况,对于性能分析和资源管理具有很大的帮助。这只是 `psutil`库功能的冰山一角,`psutil`还能够提供更多关于系统和进程的详细信息,强烈推荐进一步探索这个强大的库。
35 1
|
1月前
|
Ubuntu 编译器 C语言
Ubuntu 源码编译指定版本 make:神秘代码背后的激情冒险,等你来战!
【9月更文挑战第8天】在Ubuntu中,编译指定版本的源码`make`是一项挑战但也极具价值的任务。它允许我们根据特定需求定制软件,提升性能与功能适配。首先需安装必要工具包如GCC等;接着下载所需源码并阅读相关文档以了解编译要求。通过运行`./configure`、`make`及`sudo make install`命令完成编译安装流程。过程中可能遇到依赖项缺失或编译选项设置不当等问题,需根据错误提示逐一解决。对于大型项目,可利用多核编译加快速度。掌握这一技能有助于更好地探索开源世界。
33 2
|
19天前
|
监控 Ubuntu Python
代码实现Ubuntu系统参数监控的方法
通过这种方式,你可以方便地对Ubuntu系统的关键参数进行实时监控,对系统性能分析和资源管理具有重要意义。
28 0