我需要为 Android 应用程序构建最新的 OpenSSL (1.0.0g)。我正在尝试遵循 https://github.com/fries/android-external- 给出的示例openssl,但我就是无法构建它。
我正在运行 Windows 7 Professional(64 位)以及完整且最新的 Cygwin。我已经安装了Android SDK和NDK,并且可以成功构建并运行NDK的hello-jni示例应用程序。
我创建了一个名为 hello-openssl 的新示例 NDK 应用程序。在其 jni 目录中,我创建了一个 openssl 目录。在那里,我解压缩 https://github.com/fries/android-external-openssl /zipball/master,它在 c:\android\android-ndk\samples\hello-openssl 下给了我这个树结构:
jni
+- openssl
+- apps
+- crypto
+- include
+- openssl
+- ssl
然后我修改了 Android.mk 文件jni 目录试图包含 OpenSSL 文件:
subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
openssl \
))
include $(subdirs)
现在,当我执行 ndk-build 时,它会编译几个 .c 文件,但很快就会失败:
Compile thumb : crypto <= cryptlib.c
In file included from jni/openssl/crypto/cryptlib.c:117:
jni/openssl/crypto/cryptlib.h:65:18: error: e_os.h: No such file or directory
jni/openssl/crypto/cryptlib.h:72:28: error: openssl/crypto.h: No such file or directory
我发现 http://osdir.com/ml/android-ndk/2010-07/msg00424.html,它告诉我“添加
jni 和 jni/include 到 crypto/Android.mk 中的上述 LOCAL_C_INCLUDES" 中,但我无法弄清楚应该用来实现此目的的语法。
我也无法弄清楚我有正确的目录结构。
我真诚地 提供的任何帮助!
感谢您
I need to build the latest OpenSSL (1.0.0g) for an Android application. I am trying to follow the example given by https://github.com/fries/android-external-openssl, but I just can't get it built.
I am running Windows 7 Professional (64-bit) with a complete and recent Cygwin. I have installed the Android SDK and NDK, and I can successfully build and run the NDK's hello-jni sample application.
I created a new sample NDK app called hello-openssl. In its jni directory, I created an openssl directory. There, I unzipped https://github.com/fries/android-external-openssl/zipball/master, which gave me this tree structure under c:\android\android-ndk\samples\hello-openssl:
jni
+- openssl
+- apps
+- crypto
+- include
+- openssl
+- ssl
I then modified the Android.mk file in the jni directory in an attempt to include the OpenSSL files:
subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
openssl \
))
include $(subdirs)
Now when I execute ndk-build, it compiles several .c files, but then quickly fails:
Compile thumb : crypto <= cryptlib.c
In file included from jni/openssl/crypto/cryptlib.c:117:
jni/openssl/crypto/cryptlib.h:65:18: error: e_os.h: No such file or directory
jni/openssl/crypto/cryptlib.h:72:28: error: openssl/crypto.h: No such file or directory
I found http://osdir.com/ml/android-ndk/2010-07/msg00424.html, which tells me to "add
jni and jni/include to the above LOCAL_C_INCLUDES" in crypto/Android.mk, but I can't figure out the syntax I should use to achieve this.
I also can't figure out of I have the correct directory structure.
I sincerely appreciate any help that can be offered.
Thanks!
发布评论
评论(1)
我通过放弃 https://github.com/fries/android-external-openssl 并使用https://github.com/guardianproject/openssl-android。
它基于更新的 OpenSSL (1.0.0a),并且在 NDK 中构建,无需任何修改。
请注意,为了在 Android 应用程序中使用这些库,您必须重命名它们。如果您只是将生成的libssl.so和libcrypto.so包含在您的应用程序中,然后调用System.LoadLibrary(“crypto”)和System.LoadLibrary(“ssl”),您将获得Android系统中包含的OpenSSL库,而不是您的自定义库。
为此,只需在每个 Android.mk 中(即在 /crypto、/ssl、和/应用程序)。
然后在您的 Android 应用程序中,调用 SystemLoadLibrary ("cryptox") 和 System.LoadLibrary ("sslx")
I solved this problem by abandoning https://github.com/fries/android-external-openssl and instead using https://github.com/guardianproject/openssl-android.
It is based on a more recent OpenSSL (1.0.0a), and it builds in the NDK without any modifications.
Note that in order to use these libraries in an Android app, you must rename them. If you simply include the resulting libssl.so and libcrypto.so in your app, then call System.LoadLibrary ("crypto") and System.LoadLibrary ("ssl"), you will get the OpenSSL libraries included in the Android system, not your custom libraries.
To do this, just do a full-word search and replace ("libssl" -> "libsslx", and "libcrypto" -> "libcryptox") in each Android.mk (i.e, in /crypto, /ssl, and /apps).
Then in your Android app, call SystemLoadLibrary ("cryptox") and System.LoadLibrary ("sslx")