Compiling OpenSSL on Android

后端 未结 1 411
南笙
南笙 2020-12-18 16:49

I\'m currently trying to get my Cocos2D-X project to connect to my server through SSL and I got it to work on iOS without a lot of issues, however on Android I\'m not able t

相关标签:
1条回答
  • 2020-12-18 17:16

    Had a problem close to your. Every Android OS has libssl and libcrypto libraries that part of OpenSSL. But them not included in NDK for using them. So you can a little bit modify your NDK by copying *so files from the phone.

    $adb pull /system/lib/libssl.so /myndk/platforms/android-14/arch-arm/usr/lib
    
    $adb pull /system/lib/libcrypto.so /myndk/platforms/android-14/arch-arm/usr/lib
    

    where /myndk is path to your NDK, android-14 - your current platform

    Also copy *.h files from openssl sources to /myndk/platforms/android-14/arch-arm/usr/include folder. Also add to this folder the next file - openssl/opensslconf.h (you could found it in internet or configure from source openssl) These files needed only at compile time. Once compiled your App will get the libraries from the phone.

    Also do not forget add -lssl -lcrypto options in jni/Application.mk file for APP_LDFLAGS section

    APP_LDFLAGS := -latomic -lssl -lcrypto
    
    0 讨论(0)
提交回复
热议问题