i am trying to embed the openssl library in my Android application using Android NDK but i don't know how to use exactly that library and so please any one can tell me how to use that please send a source code for my reference.......
Related :
i am trying to embed the openssl library in my Android application using Android NDK but i don't know how to use exactly that library and so please any one can tell me how to use that please send a source code for my reference.......
Related :
Have you tried this, its a standalone build of the openssl that's included in Android: https://github.com/fries/android-external-openssl/blob/master/README.android
There are several tips about using OpenSSL with Android:
It is necessary to build OpenSSL libraries using NDK tools, otherwise they will be incompatible with the NDK. Compiling the latest OpenSSL for Android
CC=~/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc
./Configure android-armv7
export ANDROID_DEV=~/android-ndk-r9//platforms/android-8/arch-arm/usr
make build_libs
It is supposed that these commands are executed in the source directory of OpenSSL.
In order to use these libraries (ssl and crypto) with your own library from the NDK, you need to create additional *.mk files in jni folder. For example:
include $(CLEAR_VARS)
LOCAL_MODULE := ssl-crypto
LOCAL_SRC_FILES := openssl-crypto/libcrypto.so
include $(PREBUILT_SHARED_LIBRARY)
and include them into the main Android.mk:
include $(LOCAL_PATH)/openssl-ssl/Android.mk
and probably add
include $(CLEAR_VARS)
after it to avoid errors. Libraries will be placed into libs/armabi
and .apk
.
If you stumble opon could not load library ... needed by ...
error then your library may have soname
with a version number. AFAIK NDK is unable to work with such libraries at this moment. There is a workaround (Dalvik is looking for .so file with '.0' extension - why?):
rpl -R -e library.so.1.1 "library.so\x00\x00\x00\x00" libs obj
where rpl
is a linux string replacement tool. Run this script after the building and before the running of your application and it will remove the version number from the project files.
If you use a C++ compiler, you may get "undefined references" error in your C functions. Use extern "C" {}
to avoid this (see "C++ name mangling" for more info).
Make sure that there is a network permission in the manifest.