【问题标题】:Compile OpenSSL 1.1.0 for Android为 Android 编译 OpenSSL 1.1.0
【发布时间】:2017-01-31 02:22:06
【问题描述】:

我正在尝试通过 cygwin 在 Android 上编译 openssl-1.1.0,请遵循以下指南:

Compiling the latest OpenSSL for Android

但它失败了,这是错误:

crypto/aes/aes_ecb.c:10:20: fatal error: assert.h: No such file or directory
 #include <assert.h>

我使用的是 Android-ndk-r12b、Win10、cygwin 64 位。

这是我编译前的预配置:

export NDK=~/android-ndk-r12b
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-21 --toolchain=arm-linux-androideabi-4.9 --install-dir=`pwd`/android-toolchain-arm
export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm/bin
export TOOL=arm-linux-androideabi
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-mthumb"
export ARCH_LINK=
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
./Configure android
PATH=$TOOLCHAIN_PATH:$PATH make

请帮忙告诉我哪里错了

编辑:

按照jww的建议,我试试https://wiki.openssl.org/index.php/Android

我将 setenv-android.sh 中的一些配置更改为:

-_ANDROID_NDK="android-ndk-r12b"
-_ANDROID_EABI="arm-linux-androideabi-4.9"
-_ANDROID_API="android-21"

为了生成有效的工具链,我将“windows-x86_64”添加到 对于“linux-x86_64”“linux-x86”“darwin-x86_64”“darwin-x86”中的主机 现在是:

for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86" "windows-x86_64"
do
....
done

+构建openssl-1.1.0:

错误:

$ perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
Can't open Makefile.org: No such file or directory.

编辑 2:

我关注 jww 的 wiki 更新,它运行顺利,直到这个命令:

arm-linux-androideabi-gcc -I /usr/local/ssl/include my_prog.c -o my_prog.exe -L /usr/local/ssl/lib -lssl -lcrypto

如果我使用 $ANDROID_TOOCHAIN/arm-linux-androideabi-gcc -I /usr/local/ssl/include my_prog.c -o my_prog.exe -L /usr/local/ssl/lib -lssl -lcrypto ,它不理解 -Imy_prog.c

我想为 android 构建 openssl-1.1.0 但我不知道如何修复它。请帮忙

【问题讨论】:

  • 一种更简单的方法是按照来自 OpenSSL wiki 的 OpenSSL and Android 中详细说明的说明进行操作。有什么不适合你的原因吗?
  • 我也尝试过使用 setenv-android.sh 进行编译,但是对于 openssl 1.1.0 来说它失败了,这就是我转向这个的原因。也许我错过了 setenv-android.sh 中的一些配置,谢谢你的建议,我会再试一次。
  • 构建是否会告诉您失败命令的编译器命令行?
  • 是的,它告诉我 Can't open Makefile.org: No such file or directory when compile this line: $ perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw /g' Makefile.org
  • @jww 感谢您的好意,我几乎使用与您的 setenv-android.sh 中相同的配置,只需更改 _ANDROID_NDK="android-ndk-r12b" _ANDROID_EABI="arm-linux-androideabi- 4.9" _ANDROID_API=21 并将 "windows-x86_64" 添加到 "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86" 中的主机以获得有效的 ANDROID-TOOLCHAIN 路径。成功编译openssl 1.1.0就够了吗?还有一件事,使用“makedepend”然后“make all”将与“make install”产生相同的结果?

标签: android android-ndk openssl cygwin


【解决方案1】:

我试图为 Android 构建 OpenSSL 1.1.0g

android NDK android-ndk-r16b, centOS 6.9 64 bit OS.

根据https://wiki.openssl.org/index.php/Android

遇到了同样的问题

crypto/aes/aes_ecb.c:10:20: fatal error: assert.h: No such file or directory
 #include <assert.h>

经过搜索,我发现Updated NDK android-ndk-r16b 已经将sysroot 更新为android-ndk-r16b/sysroot,其中包含包含目录但没有库。

所以包含路径和库路径发生了变化

setenv-android.shsysroot 设置为

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

但这对 android-ndk-r13b 有效

我可以使用 android-ndk-r13b 成功构建 OpenSSL。

【讨论】:

  • 我仍然看到同样的问题
【解决方案2】:

请看this Github library

setenv-android.sh 不是必需的。这确实有效。

【讨论】:

  • 嗨,你能分享一下步骤吗?我在“make build”命令上遇到错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-01-20
  • 1970-01-01
  • 2012-08-09
  • 2019-03-14
  • 1970-01-01
  • 2015-04-10
  • 2018-10-18
相关资源
最近更新 更多