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

相关文章
|
21天前
|
Ubuntu 安全 数据安全/隐私保护
如何在Ubuntu系统下取消sudo的密码输入限制
以上就是如何在Ubuntu系统下取消sudo的密码输入限制的全部内容。探索的旅程是充满乐趣和挑战的,期待下一次与你的相遇,我们将开始新的知识冒险!
87 31
|
1月前
|
Ubuntu 定位技术 开发工具
在Ubuntu 20.04系统中安装SLAM库的具体操作步骤
以上是在Ubuntu 20.04系统中安装SLAM库的具体操作步骤。就像积木游戏,需要按照正确的步骤,适时地添加正确的部件,才能够构建出我们想要的积木模型。在现实操作中可能会遇到各种问题,就像积木构建中的各种困难,我们要有耐心和决心去解决它们,最后得到我们想要的结果。希望这个有趣的积木游戏比方能帮助你更好地理解SLAM库的安装过程,并在实际操作中得到应用。
82 34
|
22天前
|
Ubuntu 机器人 Shell
在Jetson TX2的Ubuntu18.04系统中安装ROS的教程
所有这些步骤并不复杂,但确实需要仔细一点。如果遇到问题,不要灰心,问题是解决问题的开始。保持耐心,细心阅读错误信息,通常情况下,问题的答案就藏在其中。祝ROS旅程顺利!
70 18
|
1月前
|
Ubuntu 数据安全/隐私保护
在Ubuntu系统中增加Openfire服务设置和管理
至此,你已经完成了在Ubuntu中增加Openfire服务的设置和管理。希望你在这个过程中,能像享受一场摇滚音乐会一样,体验编程的乐趣和成就感。祝你玩得开心!
80 27
|
1月前
|
Ubuntu Linux 测试技术
Ubuntu系统内核遭遇Kernel Panic问题
善于利用互联网资源,查找类似问题及对应解决方案。Linux社群中的各种论坛(例如 Ask Ubuntu、Ubuntu Forums和 Stack Overflow)提供很多有价值的讨论内容,可以为您排忧解难。祝您早日解决Ubuntu系统的Kernel Panic问题!
76 16
|
2月前
|
Ubuntu PHP Apache
在Ubuntu系统中为apt的apache2编译PHP 7.1的方法
以上就是在Ubuntu系统中为apt的apache2编译PHP 7.1的方法。希望这个指南能帮助你成功编译PHP 7.1,并在你的Apache服务器上运行PHP应用。
89 28
|
2月前
|
Ubuntu Linux 编译器
在Ubuntu Linux系统下如何搭建并安装EDK2
以上就是在Ubuntu Linux系统下搭建并安装EDK2的过程。这个过程可能会有些复杂,但只要按照步骤一步步来,应该不会有太大问题。如果在过程中遇到任何问题,都可以在网上找到相应的解决方案。希望这个指南能对你有所帮助!
128 17
|
Java 测试技术 持续交付
|
14天前
|
安全 Java Android开发
为什么大厂要求安卓开发者掌握Kotlin和Jetpack?深度解析现代Android开发生态优雅草卓伊凡
为什么大厂要求安卓开发者掌握Kotlin和Jetpack?深度解析现代Android开发生态优雅草卓伊凡
42 0
为什么大厂要求安卓开发者掌握Kotlin和Jetpack?深度解析现代Android开发生态优雅草卓伊凡
|
3月前
|
JavaScript Linux 网络安全
Termux安卓终端美化与开发实战:从下载到插件优化,小白也能玩转Linux
Termux是一款安卓平台上的开源终端模拟器,支持apt包管理、SSH连接及Python/Node.js/C++开发环境搭建,被誉为“手机上的Linux系统”。其特点包括零ROOT权限、跨平台开发和强大扩展性。本文详细介绍其安装准备、基础与高级环境配置、必备插件推荐、常见问题解决方法以及延伸学习资源,帮助用户充分利用Termux进行开发与学习。适用于Android 7+设备,原创内容转载请注明来源。
554 76