【发布时间】:2015-04-30 14:12:43
【问题描述】:
我是 NDK 的新手,我正在关注 guide 为 Android 构建 OpenSSL,为此我使用的是 Windows 7 和 Cygwin。
我在尝试构建 OpenSSL 库时遇到错误。
# From the 'root' directory
$ . ./setenv-android.sh
$ cd openssl-1.0.1g/
$ perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
$ ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine --openssldir=/usr/local/ssl/$ANDROID_API
$ make depend
$ make all
当我尝试 make depend 命令时,我有 2 个错误:
cryptlib.c:171:3: error: #error "Inconsistency between crypto.h and cryptlib.c"
# error "Inconsistency between crypto.h and cryptlib.c"
cryplib.c 第 171 行说:
#if CRYPTO_NUM_LOCKS != 41
# error "Inconsistency between crypto.h and cryptlib.c"
#endif
我不知道如何解决这个错误。
另一个是uid.c:77:10: error: #include expects "FILENAME" or <FILENAME>
#include OPENSSL_UNISTD
如果我将 uid.c 中的第 77 行更改为 #include <unistd.h>,我会在 Makefile 中收到错误,所以我不知道是否可以修复它,错误是在依赖 Makefile 中。
depend:
@[ -z "$(THIS)" -o -f buildinf.h ] || touch buildinf.h # fake buildinf.h if it does not exist
@[ -z "$(THIS)" ] || $(MAKEDEPEND) -- $(CFLAG) $(INCLUDE) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
@[ -z "$(THIS)" -o -s buildinf.h ] || rm buildinf.h
@[ -z "$(THIS)" ] || (set -e; target=depend; $(RECURSIVE_MAKE) )
@if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
另一个问题是我是否可以使用本指南将 OpenSSL 库构建到 64 位架构。 (x86_64、arm64 和 mips64)我没有在这些架构中找到有关 Android 的 OpenSSL 的信息,所有关于它的帖子都很旧,并且这些架构对于 Android 不存在
编辑
我找到了一种方法来部分解决我的问题(不是最好的,但它有效),问题是由于某些路径中的一些错误,因为我试图在 Windows 和一些文件上使用 Cywin(我不知道那些)试图到达一些不存在的路径,因为我在 Windows 上而不是在 Linux 上,所以我只是在虚拟机上安装 Ubuntu 并再次尝试这个guide,我可以编译库并且我有 libcrypto。 a libcrypto.so libssl.a libssl.so 适用于 Android ARM、x86、mips、ARM64 和 x86_64 架构。
但是这些库不适用于 x86_64 和 ARM64,当我尝试使用 android.mk 为 x86_64 或 arm64 eabi 编译 .c 时,由于某些兼容性错误,它无法编译,但如果尝试编译 de相同的 .c 文件与“x86_64”或“arm-64”对于 x86 或 arm eabi 它确实编译,所以它们仍然是 32 位库,这不是答案,因为我需要所有架构的库(至少对于 armv5、armv7、armv8-64、x86、x86_64),这只是一小步。
如果有人想帮助我,我会更新以帮助遇到同样问题的人。
【问题讨论】:
标签: c windows android-ndk openssl cross-compiling