【发布时间】:2018-07-02 12:41:20
【问题描述】:
我试过How to build and integrate OpenSSL into your Android NDK project – Scottyab's blog,但遇到了问题:
错误信息
openssl/x86_64/lib/libcrypto.a(eng_openssl.o):eng_openssl.c:function test_rc4_init_key: error: undefined reference to 'stderr'
openssl/x86_64/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stdin'
openssl/x86_64/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stderr'
openssl/x86_64/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stdin'
openssl/x86_64/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stderr'
我试过Compilation fails with android ndk r15b · Issue #3826 · openssl/openssl's comment,它确实消除了一个错误,但剩下的其他错误。
Compilation fails with android ndk r15b · Issue #3826 · openssl/openssl's comment 建议使用 --deprecated-headers,也没有用。
NDK: Unified Headers issue · Issue #445 · android-ndk/ndk's comment 表示已解决。我尝试设置CFLAGS=-D__ANDROID_API__=$API,但没有帮助。
我也尝试使用 clang 作为编译器并得到了
clang: error: unknown argument: '-mandroid'
Android Studio: clang error: unknown argument: '-mandroid''s answer对此有很好的解释。
其实faisal00813/openssl_for_ios_and_android: OpenSSL Library for iOS and Androidfork使用clang作为编译器,解决了-mandroid的bug,但还是得到了undefined reference to 'stdin'
【问题讨论】:
-
从所有开放的 ssl 源代码中删除“-mandroid”。我已经编译它并成功生成了 .a 文件。
标签: android android-ndk openssl