1

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 to even get OpenSSL to compile.. I've searched on Google quite a lot but all posts either keep re-directing me to HTTPS related posts (which this is not, I'm not using HTTP in any way shape or form here, purely OpenSSL), posts on how to do it with the standard Android SDK in Java or posts which just aren't helpful at all.

Can someone please show me how I can compile the Android version of this game and get it to connect to my server?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
MegaMiley
  • 478
  • 1
  • 5
  • 19

1 Answers1

2

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
Alex Bezuglyi
  • 540
  • 4
  • 9
  • 1
    Thanks!! I got it to work (though I had to change '-latomic -lssl -lcrypto' to ' -lssl -lcrypto -latomic' because it kept complaining that it couldn't load srand or rand) – MegaMiley Feb 10 '15 at 17:48
  • 1
    look: https://sourcedna.com/blog/20150806/predicting-app-crashes-on-android-m.html – EpicPandaForce Aug 07 '15 at 18:55
  • 1
    @zezioen where are the *h files ? I mean should I download them from openssl source or find it on the phone ? And how about version compability ? – Muhammet Ali Asan Mar 09 '17 at 06:35