Android的NDK OpenSSL的错误交叉编译 [英] Android NDK OpenSSL error cross-compiling

查看:1531
本文介绍了Android的NDK OpenSSL的错误交叉编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在NDK新的,我下面这个指南建立OpenSSL的为Android ,我使用的是Windows 7和Cygwin这一点。

I am new in NDK and I am following this guide to build OpenSSL for Android, I am using Windows 7 and Cygwin for this.

我试图建立OpenSSL库时有错误。

I'm having errors when trying to build the OpenSSL library.

# 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

当我尝试使依赖命令我有2个错误:

When I try the make depend command I have 2 errors:

cryptlib.c:171:3:错误:#ERRORcrypto.h和cryptlib.c之间的不一致
 #错误crypto.h和cryptlib.c之间的不一致

在cryplib.c线171说:

the cryplib.c line 171 says:

#if CRYPTO_NUM_LOCKS != 41
# error "Inconsistency between crypto.h and cryptlib.c"
#endif

我不知道如何解决这个错误。

I don't know how to fix that error.

另外一个是 uid.c:77:10:错误:#包括预计文件名或LT;文件名>
 #包括OPENSSL_UNISTD

如果我更改线路77至uid.c 的#include<&unistd.h中GT; 我得到在Makefile中的错误,所以我不知道它是解决它的方法,错误是在依赖Makefile文件。

if I change the line 77 in uid.c to #include <unistd.h> I get an error in the Makefile, so I don't know if it's the way to fix it, the error was in depend 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)我没有在这些架构中有关OpenSSL的为Android,关于它的一切都是后旧的和那些弓没有为Android的存在

Another question is if I can use this guide to build the OpenSSL library to the 64bit arch. (x86_64, arm64 and mips64) I haven't found information about OpenSSL for Android in those architectures, all post about it are old and those arch didn't exist for Android

我找到了一种方法来部分地解决我的问题(不是最好的,但它的工作原理),这个问题是由于在某些路径一些错误,因为我试图用Cywin在Windows和一些文件(我不知道这的)试图达到不存在,因为我是在Windows上,而不是在Linux中一些路径,所以我只是一个虚拟机上安装Ubuntu和尝试这个的导再次,我可以编译库和我有libcrypto.a libcrypto.so libssl.a libssl.so为Android ARM,X86,MIPS,ARM64和x86_64架构。

I found a way to solve partially my problem (not the best one but it works), the problem was due some errors in some paths, because I was trying to use Cywin on Windows and some files(I don't which ones) were trying to reach some paths that doesn't exist because I was on Windows and not in Linux, so I just install Ubuntu on a virtual machine and try this guide again, and I could compile libraries and I have libcrypto.a libcrypto.so libssl.a libssl.so for Android ARM, x86, mips, ARM64 and x86_64 Architectures.

但图书馆没有为64位x86和ARM64工作,当我尝试编译使用的x86_64或arm64 EABI的android.mk它不会因编译一些兼容性错误.c的,但如果试图编译德同.c文件的枝条x86_64的或武装-64为x86或ARM EABI它编译,所以他们仍然是一个32位的库,这不是答案,因为我需要所有的架构库(至少对于ARMv5中,ARMv7的,armv8-64,X86,x86_64的),这只是一小步。

But the libraries doesn't work for x86_64 and ARM64, when I try to compile a .c using the android.mk for x86_64 or arm64 eabi it doesn't compile due some compatibility errors, but if a try to compile de same .c file withe the "x86_64" or "arm-64" for a x86 or arm eabi it does compile, so they are still a 32bit libraries, this is not the answer because I need the libraries for all the architecture (at least for armv5, armv7, armv8-64, x86, x86_64), this is just a small step.

我将更新,以帮助有同样问题的人,如果有人想帮助我。

I will be updating to help someone with the same problem and if someone want to help me.

推荐答案

使用此引导和修改文件 setenv-android.sh 你可以很容易编译手臂,x86和MIPS的OpenSSL。

Using this guide and modifying the file setenv-android.sh you can easy compile openssl for arm, x86 and mips.

您只需要修改 _ANDROID_NDK _ANDROID_ARCH _ANDROID_EABI _ANDROID_API 参数

注意:对于MIPS你得周围添加

note: for mips you'll have to add some lines in the file around

围绕线120:

 arch-mips)   
  ANDROID_TOOLS="mipsel-linux-android-gcc mipsel-linux-android-ranlib mipsel-linux-android-ld"
;;

围绕线200:

if [ "$_ANDROID_ARCH" == "arch-mips" ]; then
   export MACHINE=mipsel
   export RELEASE=2.6.37
   export SYSTEM=android
   export ARCH=mips
   export CROSS_COMPILE="mipsel-linux-android-"
fi

如果你跟着导游你必须libcrypto.a,libssl.a,libcrypto.so和libssl.so。

if you follow the guide you'll have libcrypto.a, libssl.a, libcrypto.so and libssl.so.

如果您需要64位架构的库可以使用亚行 /系统/ lib64目录为64位版本(仅在64位设备),和 /系统/ lib目录的32位版本,您可以使用仿真器,如果你能想的64位版本在这个链接的静态库(libcrypto.a和libssl.a)的,你可以找到这样做的方式。

if you want the libraries for 64 bits architecture you can do a pull from a device using adb, all android device have libcrypto.so and libssl.so in /system/lib64 for 64bits version (only in a 64bits device), and /system/lib the 32bits version, you can use an emulator for that, if you can want the 64bits version of the static libraries (libcrypto.a and libssl.a) in this link you can find the way to do it.

这篇关于Android的NDK OpenSSL的错误交叉编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆