#/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 ..
编译的时候可能会遇到一个问题,
/bin/sh: 1: ../../bin/jsoncpp_test: Exec format error
这个其实是交叉编译引起的
可以看到里面会编译测试用例并执行,因为是交叉编译,再本机上肯定是用不了的,把它改为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)