Eelmises osas saime Boost C++ näite tööle Linuxiga. Nüüd üritame sama teha Androidiga.
Kõigepealt peame Boost C++ kompileerima Androidi jaoks. See ei olegi nii raske, kui alguses internetti läbi kammides tundub.
Boost oli meil juba alla laaditud (vaata eelmist artiklit). Seega avan Linuxi käsurea ja annan käsklused:
cd ~/boost-src/boost_1_59_0/ cp project-config.jam project-config.jam.linux.oli nano project-config.jam
Failis project-config.jam muudan rea " using gcc ;" reaks "using gcc : arm : /home/tiit/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ ;".
Seejärel annan käskluse
./b2 --reconfigure toolset=gcc-arm include=$NDK/sources/cxx-stl/gnu-libstdc++/4.9/include include=$NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include include=$NDK/platforms/android-9/arch-arm/usr/include install --libdir=stage/lib/armeabi-v7a
Tulemus:
Edasine ei ole ehk väga mõistlik, kui meil on käsil mitu projekti, mis kasutavad boost teeke. Sellisel juhul võiks vaadata, kuidas näiteks CrystaX NDK on asja lahendanud.
Lihtsuse ja selguse huvides teen praegu järgmiselt. Käsurealt annan käsklused:
mkdir -p ~/git-gtest/boostdemo/jni/boost mkdir -p ~/git-gtest/boostdemo/jni/boost/include mkdir -p ~/git-gtest/boostdemo/jni/boost/libs cd ~/boost-src/boost_1_59_0 cp -r stage/lib/armeabi-v7a/ ~/git-gtest/boostdemo/jni/boost/libs/ cp -r boost/ ~/git-gtest/boostdemo/jni/boost/include/
Android.mk faili teen nüüd selliseks:
TARGET_ARCH_ABI := armeabi-v7a LOCAL_PATH := $(call my-dir) $(info asukoht: $(LOCAL_PATH)) include $(CLEAR_VARS) LOCAL_MODULE := boost_serialization LOCAL_SRC_FILES := $(LOCAL_PATH)/boost/libs/armeabi-v7a/libboost_serialization.a LOCAL_EXPORT_C_INCLUDES := boost/include include $(PREBUILT_STATIC_LIBRARY) #siin on meie exe include $(CLEAR_VARS) LOCAL_MODULE := boostdemo FILE_LIST := $(wildcard $(LOCAL_PATH)/../../src/*.cpp) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include LOCAL_STATIC_LIBRARIES := boost_serialization include $(BUILD_EXECUTABLE)
Esimesest osast tuttavat build.bat peame samuti pisut muutma:
call "C:\Users\tiit\AppData\Local\Android\sdk\ndk-bundle\ndk-build.cmd" if %errorlevel% neq 0 exit /b %errorlevel% adb -d push ../../libs/armeabi/libgnustl_shared.so /data/local/tmp/ adb -d push ../../libs/armeabi/boostdemo /data/local/tmp/ adb -d shell chmod 775 /data/local/tmp/boostdemo adb -d shell "cd /data/local/tmp && LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/boostdemo"
Käivitan nüüd build.bat:
Viited:
http://stackoverflow.com/questions/30491158/compile-and-use-boost-for-android-ndk-r10e