gpt4 book ai didi

使用 OpenSSL 的 libcurl 的 Android-21 静态构建

转载 作者:行者123 更新时间:2023-11-29 17:22:21 26 4
gpt4 key购买 nike

我有一个用 C++11 编写的库(线程、智能指针)。对于 HTTP 支持,该库使用 libcurl 和 openssl 来支持 HTTPS。在此之前,这个库只能在 Windows 和 iOS 上工作。但我有一个任务要在 Android 上运行它。

接下来是我们的要求:

  1. NDK Android-21 平台(看起来我们在这个平台上获得了正确的 C++11 支持)。
  2. libcurl 版本 7.44.0
  3. OpenSSL 库(libcrypto、libssl)版本 1.0.2d

我想使用这个版本的库,因为我们在 Windows 和 iOS 上使用它。

我设法使用 Android-21 平台工具链为 armeabi 构建了这些库。我还设法建立了我的图书馆的来源。但是,当我将所有链接在一起时,出现了这些错误:

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'

我认为 Android 在自己的 API 中没有终端方法,因此我决定构建没有 UI(命令行界面)的 OpenSSL。但问题是 libcurl 需要此 OpenSSL 版本的 OpenSSL UI。 OpenSSL 使用用户界面抽象来协商对加密引擎中私钥的访问。

是否可以使用最新的 OpenSSL 为 android 构建 libcurl?我应该更改我的工具链吗?

最佳答案

getpwuid_r 方法直到 Android 14 才得到完全支持,这就是为什么您在使用 Android 21 构建时看不到错误的原因。请参阅此 commit它实现了 getpwuid_r。我认为其他 undefined reference 是由于类似的问题。

关于使用 OpenSSL 的 libcurl 的 Android-21 静态构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36083102/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com