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
./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
6、编译(下面这2句代码都是对的)
make depend
make all -j$(nproc)make all -j$(nproc)命令用于在编译软件时启用并行化,以利用系统中的多个 CPU 核心-j$(nproc):-j标志用于指定同时运行的作业(或进程)数量。$(nproc)是一个 shell 命令,它返回可用的处理单元数量(即 CPU 核心数量)
当你运行make all -j$(nproc)时,它会告知make使用与 CPU 核心数量相等的并行作业,这样可以显著加快构建过程。
7、最后一步:生成静态库
make install

Ubuntu 64系统编译android arm64-v8a 的openssl静态库libssl.a和libcrypto.a的更多相关文章
- android ndk-build 编译静态库libxx.a 以及Android studio openssl 静态库配置(cmake)
android ndk-build 编译静态库libxx.a 需求场景: 目前有安卓编码好的现在的openssl的两个.a,我们需要调用openssl的函数,并把功能再封装成.a; 这样使用时,在an ...
- 【转】iOS编译OpenSSL静态库(使用脚本自动编译)
原文网址:https://www.jianshu.com/p/651513cab181 本篇文章为大家推荐两个脚本,用来iOS系统下编译OpenSSL通用库,如果想了解编译具体过程,请参看<iO ...
- Ubuntu 14.04 编译 Android 4.2.2 for Tiny4412
. . . . . 在学校里是用 Redhat 6.4 编译的 Android 4.2.2 很顺利,把源码包拷贝到笔记本上的 Ubuntu 14.04 上再编译遭遇了各种坑,所以便有了这篇博客记录解决 ...
- [原]Ubuntu 14.04编译Android Kernel
如何编译android kernel参考官方文档:https://source.android.com/source/building-kernels.html 在Ubuntu 14.04上编译a ...
- android编译openssl静态库.a
github上有一个开源项目,已经为你编译openssl建好了工程. 地址:https://github.com/aluvalasuman/OpenSSL1.0.1cForAndroid 选择需要的版 ...
- iOS开发~制作同时支持armv7,armv7s,arm64,i386,x86_64的静态库.a
一.概要 平时项目开发中,可能使用第三方提供的静态库.a,如果.a提供方技术不成熟,使用的时候就会出现问题,例如: 在真机上编译报错:No architectures to compile for ( ...
- iOS开发~制作同时支持armv7,armv7s,arm64,i386,x86_64的静态库.a以及 FrameWork 的创建
armv7,armv7s,arm64,i386,x86_64 详解 一.概要 平时项目开发中,可能使用第三方提供的静态库.a,如果.a提供方技术不成熟,使用的时候就会出现问题,例如: 在真机上编译报错 ...
- Android NDK生成及连接静态库与动态库
对于Android应用开发,大部分情况下我们使用Java就能完整地实现一个应用.但是在某些情况下,我们需要借助C/C++来写JNI本地代码.比如,在使用跨平台的第三方库的时候:为了提升密集计算性能的时 ...
- VS2010编译链接openssl静态库
最近工作需要使用一些加密算法.之前尝试过cryptopp以及polarssl,听说openssl中的加密模块特别全,并且特别好用.于是想尝试一下. 一.环境配置 下载openssl,我这里使用的是op ...
- VS2012(update3)编译Qt5.1.1 32位静态库debug-and-release版及结果分享
1. 下载zip源码,我下载的是qt-everywhere-opensource-src-5.1.1.zip这个文件. 2.安装python 3.解压缩qt-everywhere-opensource ...
随机推荐
- Git 清除缓存账密
[已解决] git push 报错:git: 'credential-manager' is not a git command. See 'git --help'. 解决方案1)运行 git con ...
- [oeasy]python0127_中文系统_gbk_BIG5_南极星_内码转化
中文系统bgk 回忆上次内容 汉字字形通过 点阵式打字机 像素级寻址的屏幕 进入了计算机的世界 添加图片注释,不超过 140 字(可选) 在海峡对岸的台湾同胞 也进入了汉字时代 他 ...
- AngleScript语法
Class的使用要继承于Interface或者Mixin class.Mixinclass实际上就是类似于抽象类 ,它已经实现的,在子类里面不能实现,类似如下代码: interface AInterf ...
- OpenGL 三角形颜色插值
1.最懒的方法--Nearest Neighbor对于三角形内的点,离三个顶点谁最近,就赋值为那个顶点对应的颜色. 2.最天真的方法--Distance三角形内一点的值应该来自于三个顶点. 计算距离: ...
- Redis内存回收与缓存问题
内存回收: 1.过期key处理 通过expire命令给key设置ttl Redis本身是KV型数据库,所有数据都存在RedisDB结构体中,其中有两张哈希表 dict:用于存放KV(这里K是K,V是V ...
- Activity活动生命相关
启动与结束 页面跳转: startActivity(new Intent(this,xxxx.class)); 关闭当前界面返回上一界面 finish(); //这里我在使用finish遇到一个问题, ...
- tensorflow/pytorch/mindspore在VGG16前向传播上的性能对比
首先说下mindspore,作为华为的主打软件产品,该计算框架可用性一直较差,不同版本不同计算硬件下的代码往往都不是完全兼容的,也就是说你在mindspore的官网上找到的VGG预训练模型的代码是mi ...
- WPF Boolean类型转化器收集 反转转化器
参考链接 https://stackoverflow.com/questions/534575/how-do-i-invert-booleantovisibilityconverter Boolean ...
- springboot接口入参下划线转驼峰以及返回参数驼峰转下划线实现
1.背景 在实际开发中,通常来说java里面是使用驼峰的命名规则; 但是有时候在对接其他三方平台的接口时,要求使用下划线的命名规则,这时候就涉及到如何让自己的接口满足三方平台的下划线; 实现方式有 1 ...
- Hutool常用工具类
1.背景 实际开发中经常用到很多的工具类,这里hutool提供了一系列的工具类,下面重点介绍常用的工具类. 2.使用步骤 官方文档:https://hutool.cn/docs/#/ 添加依赖 < ...