我正在尝试创建一个具有SSL支持的Android 64位libcurl静态库。
我首先在脚本https://github.com/cocochpie/android-openssl/blob/master/build-all-arch.sh的帮助下编译OpenSSL。我已经对其进行了修改,以便仅针对Android 64位版本构建,并且看到以下输出:
ANDROID_TOOLS = aarch64-linux-android-gcc aarch64-linux-android-gcc-ranlib aarch64-linux-android-ld
Error: ANDROID_SYSROOT is not valid. Please edit this script.
CHECK_CROSS_COMPILER =
arch = arm64
ANDROID_NDK_ROOT: /opt/android/ndk-bundle
ANDROID_ARCH: arch-arm64
ANDROID_EABI: aarch64-linux-android-4.9
ANDROID_API: android-19
ANDROID_SYSROOT: /opt/android/ndk-bundle/platforms/android-19/arch-arm64
ANDROID_TOOLCHAIN: /opt/android/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin
FIPS_SIG: /openssl-1.1.0g/util/incore
CROSS_COMPILE:
ANDROID_DEV: /opt/android/ndk-bundle/platforms/android-19/arch-arm64/usr
CROSS COMPILE ENV :
Can't open Makefile.org: No such file or directory.
Configuring OpenSSL version 1.1.0g (0x1010007fL)
no-afalgeng [forced] OPENSSL_NO_AFALGENG
no-apps [forced] OPENSSL_NO_APPS
no-asan [default] OPENSSL_NO_ASAN
no-asm [option] OPENSSL_NO_ASM
no-capieng [forced] OPENSSL_NO_CAPIENG
no-comp [option] OPENSSL_NO_COMP (skip dir)
no-crypto-mdebug [default] OPENSSL_NO_CRYPTO_MDEBUG
no-crypto-mdebug-backtrace [default] OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
no-dynamic-engine [forced]
no-ec_nistp_64_gcc_128 [default] OPENSSL_NO_EC_NISTP_64_GCC_128
no-egd [default] OPENSSL_NO_EGD
no-engine [option] OPENSSL_NO_ENGINE (skip engines)
no-fuzz-afl [default] OPENSSL_NO_FUZZ_AFL
no-fuzz-libfuzzer [default] OPENSSL_NO_FUZZ_LIBFUZZER
no-heartbeats [default] OPENSSL_NO_HEARTBEATS
no-hw [option] OPENSSL_NO_HW
no-md2 [default] OPENSSL_NO_MD2 (skip dir)
no-msan [default] OPENSSL_NO_MSAN
no-rc5 [default] OPENSSL_NO_RC5 (skip dir)
no-sctp [default] OPENSSL_NO_SCTP
no-shared [option]
no-ssl-trace [default] OPENSSL_NO_SSL_TRACE
no-ssl3 [option] OPENSSL_NO_SSL3
no-ssl3-method [default] OPENSSL_NO_SSL3_METHOD
no-stdio [option] OPENSSL_NO_STDIO
no-tests [forced] OPENSSL_NO_TESTS
no-threads [option]
no-ubsan [default] OPENSSL_NO_UBSAN
no-unit-test [default] OPENSSL_NO_UNIT_TEST
no-weak-ssl-ciphers [default] OPENSSL_NO_WEAK_SSL_CIPHERS
no-zlib [option]
no-zlib-dynamic [default]
Configuring for linux-generic64
CC =arm-linux-androideabi-gcc
CFLAG =-Wall -O3 -fPIC -mandroid -I/opt/android/ndk-bundle/platforms/android-19/arch-arm64/usr/include -B/opt/android/ndk-bundle/platforms/android-19/arch-arm64/usr//lib -O3 -fomit-frame-pointer -Wall
SHARED_CFLAG =-fPIC -DOPENSSL_USE_NODELETE
DEFINES =DSO_DLFCN HAVE_DLFCN_H NDEBUG OPENSSL_NO_DYNAMIC_ENGINE OPENSSL_PIC B_ENDIAN SHARED_EXTENSION=.so OPENSSL_PIC DSO_DLFCN HAVE_DLFCN_H
LFLAG =
PLIB_LFLAG =
EX_LIBS =-ldl
APPS_OBJ =
CPUID_OBJ =mem_clr.o
UPLINK_OBJ =
BN_ASM =bn_asm.o
EC_ASM =
DES_ENC =des_enc.o fcrypt_b.o
AES_ENC =aes_core.o aes_cbc.o
BF_ENC =bf_enc.o
CAST_ENC =c_enc.o
RC4_ENC =rc4_enc.o rc4_skey.o
RC5_ENC =rc5_enc.o
MD5_OBJ_ASM =
SHA1_OBJ_ASM =
RMD160_OBJ_ASM=
CMLL_ENC =camellia.o cmll_misc.o cmll_cbc.o
MODES_OBJ =
PADLOCK_OBJ =
CHACHA_ENC =chacha_enc.o
POLY1305_OBJ =
BLAKE2_OBJ =
PROCESSOR =
RANLIB =arm-linux-androideabi-ranlib
ARFLAGS =
PERL =/usr/bin/perl
由于/openssl-1.1.0g目录以libssl.a和libcrypto.a结尾,这似乎已成功完成。
然后我下载curl并运行以下配置:
./configure \
--host=$CHOST \
--target=aarch64-linux-android \
--with-ssl=/openssl-1.1.0g \
--with-zlib \
--enable-ftp \
--enable-http \
--enable-ipv6 \
--enable-static \
--disable-dict \
--disable-file \
--disable-gopher \
--disable-imap \
--disable-ldap \
--disable-ldaps \
--disable-manual \
--disable-pop3 \
--disable-proxy \
--disable-rtsp \
--disable-shared \
--disable-smb \
--disable-smtp \
--disable-sspi \
--disable-telnet \
--disable-tftp \
--without-gnutls \
--without-libidn \
--without-librtmp
此命令的输出为:
curl version: 7.56.1
Host setup: aarch64-unknown-linux-android
Install prefix: /usr/local
Compiler: arm-linux-androideabi-gcc
SSL support: no (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} )
SSH support: no (--with-libssh2)
zlib support: enabled
GSS-API support: no (--with-gssapi)
TLS-SRP support: no (--enable-tls-srp)
resolver: POSIX threaded
IPv6 support: enabled
Unix sockets support: enabled
IDN support: no (--with-{libidn2,winidn})
Build libcurl: Shared=no, Static=yes
Built-in manual: no (--enable-manual)
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
SSPI support: no (--enable-sspi)
ca cert bundle: no
ca cert path: no
ca fallback: no
LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS support: no (--enable-ldaps)
RTSP support: no (--enable-rtsp)
RTMP support: no (--with-librtmp)
metalink support: no (--with-libmetalink)
PSL support: no (libpsl not found)
HTTP2 support: disabled (--with-nghttp2)
Protocols: FTP HTTP
如果我正确地解释了这一点,则libcurl配置未找到SSL库并且在没有SSL支持的情况下进行构建。
对吗?如果是这样,我猜想如果a)找不到所需的文件或b)确实找到了所需的文件,但它们针对不同的体系结构进行了编译,则会发生这种情况。
有人可以指出我在哪里出问题了吗?
更新1
根据建议,我浏览了config.log文件。这部分看起来可疑:
COLLECT_GCC_OPTIONS='-o' 'conftest' '-v' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfp' '-mthumb' '-D' '__ANDROID_API__=19' '-Werror=implicit-function-declaration' '-O2' '-Wno-system-headers' '-v' '-mandroid' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfp' '-mthumb' '-D' '__ANDROID_API__=19' '-D' 'ANDROID' '-I' '/openssl-1.1.0g/include' '-I' '/openssl-1.1.0g/include/openssl' '-L/opt/android/toolchain-arm/include' '-march=armv7-a' '-L/openssl-1.1.0g/lib' '-mtls-dialect=gnu'
/opt/android/toolchain-arm/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/collect2 -plugin /opt/android/toolchain-arm/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/liblto_plugin.so -plugin-opt=/opt/android/toolchain-arm/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper -plugin-opt=-fresolution=/tmp/ccFgY2c5.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-ldl -plugin-opt=-pass-through=-lgcc --sysroot=/opt/android/toolchain-arm/sysroot --eh-frame-hdr -dynamic-linker /system/bin/linker -X -m armelf_linux_eabi -z noexecstack -z relro -z now -o conftest /opt/android/toolchain-arm/sysroot/usr/lib/crtbegin_dynamic.o -L/opt/android/toolchain-arm/include -L/openssl-1.1.0g/lib -L/opt/android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb -L/opt/android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb -L/opt/android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x -L/opt/android/toolchain-arm/bin/../lib/gcc -L/opt/android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib -L/opt/android/toolchain-arm/sysroot/usr/lib --fix-cortex-a8 /tmp/ccxx0SSC.o -lcrypto -lz -lgcc -lc -ldl -lgcc /opt/android/toolchain-arm/sysroot/usr/lib/crtend_android.o
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stdin'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stderr'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stdin'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stderr'
collect2: error: ld returned 1 exit status