简体   繁体   中英

Android-21 static build of libcurl with OpenSSL

I have a library written with C++11 (thread, smart pointers). For HTTP support this library uses libcurl with openssl for HTTPS support. Before this lib had to work only at Windows and iOS. But I got a task to run it on Android.

Our requirements is next:

  1. NDK Android-21 platform (looks like on this platform we get correct C++11 support).
  2. libcurl version 7.44.0
  3. OpenSSL libraries (libcrypto, libssl) version 1.0.2d

I want to use this versions of libs, because we are using it at Windows and iOS.

I managed to build those libraries for armeabi with Android-21 platform toolchain. Also I managed to build sources of my library. But when I link all together I got those errors:

third_party/android/prebuilt/arm\libcurl.a(libcurl_la-curl_ntlm_wb.o): In function `ntlm_wb_init':
curl_ntlm_wb.c:(.text+0x194): undefined reference to `getpwuid_r'
curl_ntlm_wb.c:(.text+0x314): undefined reference to `getpwuid_r'
jni/../../../stsw_third_party/android/prebuilt/arm\libcrypto.a(ui_openssl.o): In function `read_string_inner':
ui_openssl.c:(.text+0x16c): undefined reference to `signal'
ui_openssl.c:(.text+0x294): undefined reference to `tcsetattr'
ui_openssl.c:(.text+0x330): undefined reference to `tcsetattr'
jni/../../../stsw_third_party/android/prebuilt/arm\libcrypto.a(ui_openssl.o): In function `open_console':
ui_openssl.c:(.text+0x5fc): undefined reference to `tcgetattr'

I think that Android does not have terminal methods in own API and I decided to build OpenSSL without UI (command line interface). But the problem is that libcurl requires OpenSSL UI with this OpenSSL version. OpenSSL uses user interface abstraction to negotiate access to private keys in the cryprographical engines.

Is it possible to build libcurl for android with latest OpenSSL? Should I change my toolchain?

The method getpwuid_r wasn't fully supported until Android 14, which is why you aren't seeing errors when building with Android 21. See this commit which implements getpwuid_r . I think the other undefined references are due to a similar problem.

Androdi-21与libcurl和OpenSSL完美配合,使用Android-8构建产生这些错误的最终库。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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