| # 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 发布
本文详细介绍了如何在Android NDK环境下集成Protobuf库,并利用MiniCaffe进行本地的深度学习推理。首先,讲述了Android Studio配置NDK的步骤,接着讨论了 Protobuf 的编译和链接过程,确保模型定义文件能在Android环境中解析。然后,重点讲解MiniCaffe的移植,包括源码修改、编译选项设置以及如何将预训练模型转换为适用于Android平台的格式。最后,给出了在Android应用中调用C++接口进行预测的示例代码,展示了如何在移动设备上实现轻量级的深度学习应用。
577

被折叠的 条评论
为什么被折叠?



