Saturday, May 21, 2016

Compiling POCO libraries for Android



Create a standard toolchain

http://developer.android.com/ndk/guides/standalone_toolchain.html


$NDK_ROOT/build/tools/make-standalone-toolchain.sh \
--arch=arm --platform=android-18 --toolchain=arm-linux-androideabi-4.8 --install-dir=/Users/saba/azhar/work/android/POCO/poco-android-toolchain

————————————————————————
On El-Captain Install the openssl (openssl should be already present on a linux system)

brew install openssl
brew link openssl --force


————————————————————————

POCO build complete edition with NetSSL_OpenSSL and Crypto(without ODBC and MySQL)

cd /Users/ss/aa/work/android/POCO/poco-1.6.1-all_Shared

export PATH=$PATH:/Users/ss/aa/work/android/POCO/poco-android-toolchain/bin

./configure --config=Android --no-samples --no-tests --omit=Data/ODBC,Data/MySQL --include-path=/usr/local/Cellar/openssl/1.0.2d_1/include --library-path=/usr/local/Cellar/openssl/1.0.2d_1/lib

make -s -j4
————————————————————————

POCO build basic edition 

cd /Users/ss/aa/work/android/poco-1.6.1

export PATH=$PATH:/Users/ss/aa/work/android/POCO/poco-android-toolchain/bin

./configure --config=Android --no-samples --no-tests

make -s -j4

————————————————————————

By default POCO will compile static libs (.a) files but yet I haven't been able to successfully create a JNI wrapper to use functions available in static libs. So I compiled the shared libs and used them.

To generate shared libs open the below make file
/Users/ss/aa/work/android/POCO/poco-1.6.1-all_Shared/build/config/Android 

and change from

LINKMODE           ?= STATIC

to

LINKMODE           ?= SHARED


After the complete POCO libs are built they should be available in lib folder present under Root of POCO  (poco-1.6.1-all_Shared and poco-1.6.1 in my case)

Although I could generate all static libs, I could not generate the libPocoNetSSL.so lib.
I guess it was because the openssl lib that the POCO code referes to was using a static lib on MAC and creating a shared lib using static lib was causing some problem.

I speculate that the problem should not exist on a linux machine. Will try out soon and post the results.

————————————————————————

Do a clean up of POCO

make clean
rm -f -R lib
popd

rm -f -R Platform/Android/lib

rm -f -R Platform/iOS/lib

rm -f -R Platform/MacOS/lib

rm -f -R Build/iOS

rm -f -R Build/Android

rm -f -R Build/Darwin

————————————————————————
System 

OS X El Capitan
————————————————————————


Reference : -

http://pocoproject.org/docs/99300-AndroidPlatformNotes.html 



3 comments: