# Step 1. Check out the release branch or commit. | |
git checkout v3.2.0 | |
# Step 2. Create build-armeabi-v7a folder for storing generated files. | |
cd cmake && mkdir build-armeabi-v7a && cd build-armeabi-v7a | |
# Step 3. Generate Makefile with CMake. | |
# -Dprotobuf_BUILD_SHARED_LIBS=ON By default is static library (*.a file). I want a | |
# shared library (*.so file). | |
# -DCMAKE_INSTALL_PREFIX Because it's a cross-compiled library. You probably | |
# want to install the header files and shared library | |
# in specific folder rather than default /usr/local | |
# directory. | |
# -DANDROID_STL=c++_shared For the library using C++11, link to C++11 runtime. | |
# -DANDROID_LINKER_FLAGS="-landroid -llog" For the library using functions of libandroid.so | |
# and liblog.so. | |
# -DANDROID_CPP_FEATURES="rtti exceptions" Most ppl use exception and runtime-type-information | |
# features in their C++ projects. | |
# | |
# Debug Tips: | |
# Add -LAH to see variables. | |
$ANDROID_CMAKE \ | |
-Dprotobuf_BUILD_SHARED_LIBS=ON \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_TOOLCHAIN_FILE=/<your_path>/android.toolchain.cmake \ | |
-DCMAKE_INSTALL_PREFIX=/<your_install_path>/protobuf \ | |
-DANDROID_NDK=/Users/<your_user_name>/Library/Android/sdk/ndk-bundle \ | |
-DANDROID_TOOLCHAIN=clang \ | |
-DANDROID_ABI=armeabi-v7a \ | |
-DANDROID_NATIVE_API_LEVEL=16 \ | |
-DANDROID_STL=c++_shared \ | |
-DANDROID_LINKER_FLAGS="-landroid -llog" \ | |
-DANDROID_CPP_FEATURES="rtti exceptions" \ | |
.. | |
# Step 4. Run Make with generated Makefile. | |
$ANDROID_CMAKE --build . | |
# Step 5 (optional). Install the generated header files and shared library | |
# to specific folder. | |
make install |
android ndk protobuf minicaffe
最新推荐文章于 2024-12-30 16:12:35 发布