【问题标题】:Not able to compile openssl for android无法为 android 编译 openssl
【发布时间】:2020-01-20 07:53:04
【问题描述】:

我正在尝试为 android 编译 openssl 并面临一些问题。我正在按照this link 中给出的步骤进行操作。

我正在使用 NDK 版本 r20 和 OpenSSL 1.1.1c 并在 linux 机器上。

我面临两个问题:

(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) 我无法为任何其他架构进行编译。如果我将架构更改为“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
 ^

我正在通过更改“file-launcher-sh”中的“architecture=android-arm”来更改架构。我需要修改任何其他变量/宏吗?

【问题讨论】:

    标签: android android-ndk openssl


    【解决方案1】:

    您为比您的应用更新的 API 级别构建了 openssl,因此该库与您的应用不兼容。以下是我使用 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
    

    【讨论】:

      【解决方案2】:

      我只需要为每个新架构打开新的腻子。

      我认为,当我使用新架构重新运行脚本时,为一种架构导出的配置/变量中几乎没有得到更新。

      【讨论】:

        【解决方案3】:

        将编译器标志“no-asm”添加到./Configure

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

        【讨论】:

          猜你喜欢
          • 2017-01-31
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-08-09
          • 2019-03-14
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多