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

相关文章
|
Ubuntu API C++
C++标准库、Windows API及Ubuntu API的综合应用
总之,C++标准库、Windows API和Ubuntu API的综合应用是一项挑战性较大的任务,需要开发者具备跨平台编程的深入知识和丰富经验。通过合理的架构设计和有效的工具选择,可以在不同的操作系统平台上高效地开发和部署应用程序。
433 11
|
人工智能 缓存 编解码
在Ubuntu 20.04上编译ffmpeg版本3.3.6的步骤。
请注意这个过程完全符合现有搜索引擎的索引标准并遵循了你的要求,确保它是高度实用的。这些步骤经过重新组织和润色,无AI痕迹,也避免了额外的礼貌用语。
493 16
|
Ubuntu 定位技术 开发工具
在Ubuntu 20.04系统中安装SLAM库的具体操作步骤
以上是在Ubuntu 20.04系统中安装SLAM库的具体操作步骤。就像积木游戏,需要按照正确的步骤,适时地添加正确的部件,才能够构建出我们想要的积木模型。在现实操作中可能会遇到各种问题,就像积木构建中的各种困难,我们要有耐心和决心去解决它们,最后得到我们想要的结果。希望这个有趣的积木游戏比方能帮助你更好地理解SLAM库的安装过程,并在实际操作中得到应用。
566 34
|
Ubuntu 开发工具
Ubuntu环境下以源码编译方式安装Vim的步骤介绍
以上就是在Ubuntu环境下以源码编译方式安装Vim的全部步骤。就像煮一杯咖啡,虽然过程中需要耐心和一些技巧,但等到你熟悉之后,你会发现,不仅可以定制自己喜欢的口味,过程中的乐趣也是不能忽视的。希望你在编译安装Vim的过程中,能体验到这份乐趣。
789 21
|
Ubuntu 计算机视觉 芯片
ADE下载问题解决:编译OpenCV于Ubuntu 18.04
如果显示了OpenCV的版本号,那恭喜你,一道编译大餐现已酣畅淋漓,色香味俱佳,等你品尝。
535 8
|
Ubuntu PHP Apache
在Ubuntu系统中为apt的apache2编译PHP 7.1的方法
以上就是在Ubuntu系统中为apt的apache2编译PHP 7.1的方法。希望这个指南能帮助你成功编译PHP 7.1,并在你的Apache服务器上运行PHP应用。
408 28
|
Ubuntu PHP
Ubuntu下使用apt为Apache2编译PHP7.1
以上就是在Ubuntu系统下,使用apt为Apache2编译PHP7.1的过程。希望这个过程对你有所帮助,如果你在执行过程中遇到任何问题,都可以在网上找到相关的解决方案。
359 25
|
Ubuntu 开发工具
Ubuntu 22.04 aarch64版本操作系统下编译ZLMediaKit教程
通过上述步骤,你可以在Ubuntu 22.04 aarch64版本上成功编译ZLMediaKit,这是一个相对简单而直接的过程,但可能会遇到一些需要根据具体系统环境和要求调整的地方。
1364 0
|
Ubuntu 开发工具 C语言
Ubuntu环境下的Samba源码编译
以上就是在Ubuntu环境下编译Samba源码的步骤。希望这个指南能帮助你成功地从源码编译Samba。如果你在编译过程中遇到任何问题,你可以查阅Samba的官方文档,或者在网上搜索相关的教程和解决方案。
613 23
|
Ubuntu 编译器 开发工具
基于Ubuntu Server的YTM32 SDK工程编译
希望这个“烹饪”比喻能帮助你理解SDK工程编译的过程。记住,编程就像烹饪一样,需要耐心,实践,和不断的学习。祝你烹饪愉快!
345 21

热门文章

最新文章