#/bin/bash
export ANDROID_NDK=your_ndk_path
rm -r build
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="armeabi-v7a" \
-DANDROID_NDK=$ANDROID_NDK \
-DANDROID_PLATFORM=android-22 \
..
make && make install
cd ..
編譯的時(shí)候可能會(huì)遇到一個(gè)問(wèn)題,
/bin/sh: 1: ../../bin/jsoncpp_test: Exec format error
這個(gè)其實(shí)是交叉編譯引起的

image.png
可以看到里面會(huì)編譯測(cè)試用例并執(zhí)行,因?yàn)槭墙徊婢幾g,再本機(jī)上肯定是用不了的,把它改為OFF就好了
option(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" OFF)
option(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" OFF)