1

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?

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Androdi-21 works perfect with libcurl and OpenSSL, used Android-8 for building final library which produce those errors.

3 Comments

Why are you building with Android 8 if your requirement is to support Android 21?
Following is my error : /armeabi/libcurl.a(ui_openssl.o):function read_string_inner: error: undefined reference to 'bsd_signal' /usr/local/google/buildbot/src/android/ndk-r12-release/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/atomic:922: error: undefined reference to '__atomic_fetch_add_4' etc etc Facing the same issue. My curl is pre-built with Android-9 and so I am building with Android-21. The solution you posted is it correct way to do that?
Moreover I have jsoncpp and pugi built with android-21 while building final .so I need to include these 2 .a also.please help regarding the issue. Android-8 built final library will not be useful with latest Android releases .. right? Then what's the use of it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.