本文介绍了在 Android 上编译 OpenSSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试让我的 Cocos2D-X 项目通过 SSL 连接到我的服务器,并且我让它在 iOS 上运行没有很多问题,但是在 Android 上我什至无法让 OpenSSL 进行编译.. 我在谷歌上搜索了很多,但所有帖子要么一直将我重定向到与 HTTPS 相关的帖子(这不是,我在这里没有以任何形式或形式使用 HTTP,纯粹是 OpenSSL),帖子在如何使用 Java 中的标准 Android SDK 或根本没有帮助的帖子来做到这一点.

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?

推荐答案

有一个与您很接近的问题.每个 Android 操作系统都有属于 OpenSSL 的 libssl 和 libcrypto 库.但是它们未包含在 NDK 中以供使用.所以你可以通过从手机复制 *so 文件来稍微修改你的 NDK.

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

其中/myndk 是 NDK 的路径,android-14 - 您当前的平台

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

同时将 *.h 文件从 openssl 源复制到/myndk/platforms/android-14/arch-arm/usr/include 文件夹.还将下一个文件添加到此文件夹中 - openssl/opensslconf.h(您可以在互联网上找到它或从源代码 openssl 配置)这些文件只在编译时需要.编译后,您的应用将从手机中获取库.

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.

另外不要忘记在 jni/Application.mk 文件中为 APP_LDFLAGS 部分添加 -lssl -lcrypto 选项

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

APP_LDFLAGS := -latomic -lssl -lcrypto

这篇关于在 Android 上编译 OpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 04:56