简体   繁体   English

无法为 android 编译 openssl

[英]Not able to compile openssl for android

I am trying to compile openssl for android and facing some issues.我正在尝试为 android 编译 openssl 并面临一些问题。 I am following the steps given in this link .我正在按照此链接中给出的步骤进行操作。

I am using NDK version r20 and OpenSSL 1.1.1c and on a linux machine.我在 linux 机器上使用 NDK 版本 r20 和 OpenSSL 1.1.1c。

I am facing two issues:我面临两个问题:

(1) I am able to compile libs for “android-arm” architecture but getting the below errors while compiling sample application. (1) 我能够为“android-arm”架构编译库,但在编译示例应用程序时出现以下错误。

./libcrypto.so: error: undefined reference to ‘sigdelset’
./libcrypto.so: error: undefined reference to ‘sigfillset’
./libcrypto.so: error: undefined reference to ‘tcgetattr’
./libcrypto.so: error: undefined reference to ‘tcsetattr’
apps/ocsp.o:ocsp.c:function ocsp_main: error: undefined reference to ‘signal’
apps/ocsp.o:ocsp.c:function ocsp_main: error: undefined reference to ‘signal’
apps/ocsp.o:ocsp.c:function ocsp_main: error: undefined reference to ‘signal’
apps/ocsp.o:ocsp.c:function ocsp_main: error: undefined reference to ‘signal’
apps/ocsp.o:ocsp.c:function process_responder: error: undefined reference to ‘__FD_SET_chk’
apps/ocsp.o:ocsp.c:function process_responder: error: undefined reference to ‘__FD_SET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_SET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_SET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_ISSET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_ISSET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_ISSET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_ISSET_chk’
apps/speed.o:speed.c:function speed_main: error: undefined reference to ‘atof’
apps/speed.o:speed.c:function speed_main: error: undefined reference to ‘atof’
apps/speed.o:speed.c:function speed_main: error: undefined reference to ‘atof’
apps/speed.o:speed.c:function speed_main: error: undefined reference to ‘atof’
clang: error: linker command failed with exit code 1 (use -v to see invocation)

(2) I am not able to compile for any other architecture. (2) 我无法为任何其他架构进行编译。 If I change architecture to “android-arm64” (or any other), I am getting the below errors while compiling library.如果我将架构更改为“android-arm64”(或任何其他),我会在编译库时收到以下错误。

crypto/aes/aesv8-armx.S:5:1: error: Unknown arch name
.arch armv8-a+crypto
^
crypto/aes/aesv8-armx.S:17:2: error: invalid instruction, did you mean: stc, stm, str, swp, tst?
 stp x29,x30,[sp,#-16]!
 ^
crypto/aes/aesv8-armx.S:18:6: error: operand must be a register in range [r0, r15]
 add x29,sp,#0
 ^
crypto/aes/aesv8-armx.S:19:6: error: operand must be a register in range [r0, r12] or r14
 mov x3,#-1
 ^

I am changing the architecture by changing the “ architecture=android-arm ” in the “file-launcher-sh”.我正在通过更改“file-launcher-sh”中的“ architecture=android-arm ”来更改架构。 Do I need to modify any other variables/macros?我需要修改任何其他变量/宏吗?

You built openssl for a newer API level than your app, so the library is not compatible with your app.您为比您的应用程序更新的 API 级别构建了 openssl,因此该库与您的应用程序不兼容。 Here's how I build openssl with r20:以下是我使用 r20 构建 openssl 的方法:

$ export ANDROID_NDK=/path/to/ndk
$ export PATH=$ANDROID_NDK/toolchains/llvm/prebuilt/$HOST/bin:$PATH
$ path/to/openssl/Configure android-$ARCH -D__ANDROID_API__=$MINSDKVERSION --prefix=$INSTALLPATH --openssldir=$INSTALLPATH shared
$ make SHLIB_EXT=.so install_sw

I just had to open new putty for each new architecture.我只需要为每个新架构打开新的腻子。

I think somehow few of the configurations/variables exported for one architecture are not getting updated when I re-run the script with new architecture.我认为当我使用新架构重新运行脚本时,为一种架构导出的配置/变量中很少有更新。

Add the compiler flag " no-asm " to./Configure将编译器标志“ no-asm ”添加到./Configure

./Configure no-asm no-shared android-$ARCH -D__ANDROID_API__=$MINSDKVERSION --prefix=$INSTALLPATH --openssldir=$INSTALLPATH shared

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM