c - Linking so file within android ndk -
I am trying to use openssl inside an Android NDK.
I have used openssl source code, which is capable of creating libssl.so and libcrypto.so files.
Currently I am stuck in connecting those 2 files with my Jenny interface C file.
Below are my Android .mk file, called my JNI interface of file "security.c"
LOCAL_PATH: = $ # Prebuilt include libssl (call my-directory ) $ (CLEAR_VARS) LOCAL_MODULE: = ssl LOCAL_SRC_FILES: $ $ (PREBUILT_SHARED_LIBRARY) $ prebuilt libcrypto Include $ (CLEAR_VARS) LOCAL_MODULE: = Crypto LOCAL_SRC_FILES: $ libprebuilt / libcrypto.so $ (PREBUILT_SHARED_LIBRARY) $ (CLEAR_VARS) included LOCAL_MODULE = Security LOCAL_SRC_FILES: = security.c LOCAL_SHARED_LIBRARIES = SSL crypto include $ (BUILD_SHARED_LIBRARY) in and this is my security. c file
# Include & lt; Math.h> # Include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; # Include & lt; Time.h> # Include & lt; Jni.h & gt; #include "Openssl / Bayokh" #include "Openssl / Sslkh" #include "Openssl / Arrkh" Jawa_com_test_stringfromjni (Jnienv * AND, Jobjekt Thyj) {Ssl_lod_arr_strings () Jastring; ERR_load_BIO_strings (); OpenSSL_add_all_algorithms (); Return (* env) - & gt; NewstringUtf (NV, "Hello JNI"); Android Andike: Warning: APP_PLATFORM Android-19 is larger than Android: minSdkVersion 8 in / user / huydo / cur-project / company / kimisaki_native / android_os / ensemble_girls / AndroidManifest.xml [armeabi-v7a] Install: libcrypto.so = & Gt; Libs / armeabi-v7a / libcrypto.so [armeabi-v7a] Collect thumb: Security & lt; = Security.c [armeabi-v7a] SharedLibrary: libsecurity.so [armeabi-v7a] Install: libsecurity.so = & gt; Libs / armeabi-v7a / libsecurity.so [armeabi-v7a] Install: libssl.so = & gt; Libs / armeabi-v7a / libssl.so [armeabi] Install: libcrypto.so = & gt; Libs / armeabi / libcrypto.so [armeabi] Compile Thumb: Security & lt; = Security.c [armeabi] Shared library: libsecurity.so [armeabi] Install: libsecurity.so => Libs / armeabi / libsecurity.so [armeabi] Install: libssl.so = & gt; Libs / armeabi / libssl.so [x86] Install: libcrypto.so = & gt; libs / 86 / libcrypto.so /Users/huydo/android-ndk-r9d/toolchains/x86-4.6/prebuilt/darwin-x86_64/bin/i686-linux-android-strip: unable to format the input file `/ users / huydo / cur-project / XXX / android_os / YYY / libs / x86 / libcrypto.so 'make: *** [/ users / huydo / CUR- project / XXX / android_os / YYY / libs / 86 / libcrypto. Therefore] make the error 1: *** delete the file / users / hundoo / tur-project / xx / android / live / lib / x86 / libkripoto '' Then and libcrypto.so has been copied correctly into armeabi and armeabi-v7a. It was stuck while building for MMS and X86 architecture. If you have experienced this error, then you can give me glue what happened.
You are using the same ARM libssl.so and libcrypto.so when compiling for every architecture , Which can not work.
You need to use prebuilts to target the proper architecture. For this you have libprebuilt each architecture ( armeabi , armeabi-v7a , x86 , x86 ) inside, Em> mips ), add your prebuilts. Your .so files to refer to each of these files, and $ (TARGET_ARCH_ABI) inside your Android.mk : < Code> LOCAL_PATH: = $ # prebuilt libssl included $ (CLEAR_VARS) LOCAL_MODULE: = ssl LOCAL_SRC_FILES: = libprebuilt / $ (TARGET_ARCH_ABI) /libssl.so $ (INCLUDED PREBUILT_SHARED_LIBRARY) # Pribilit Libripcript $ (CLEAR_VARS) LOCAL_MODULE includes: = crypto LOCAL_SRC_FILES: = libprebuilt / $ (TARGET_ARCH_ABI) /libcrypto.so Include $ (PREBUILT_SHARED_LIBRARY) $ (CLEAR_VARS) LOCAL_MODULE Includes: = Security LOCAL_SRC_FILES: = security.c LOCAL_SHARED_LIBRARIES = ssl cripple Tow include $ (BUILD_SHARED_LIBRARY) in If you do not get the x86 version of libssl.so and libcrypto.so, you can remove them x 86 emulator.
To specify which architecture you want to t for example: APP_ABI: = armeabi-v7a x86 mips APPAB Use the variable application.mk , / div>
Comments
Post a Comment