Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tcw165/387ea0ee5c5c0c596257277a4addf87a to your computer and use it in GitHub Desktop.
Save tcw165/387ea0ee5c5c0c596257277a4addf87a to your computer and use it in GitHub Desktop.
# Step 1. Switch to the release commit. For example: v19.4.
git checkout v19.4
# Step 2. Create the build folder for storing generated files.
cd dlib && mkdir build-armeabi-v7a && cd build-armeabi-v7a;
# Step 3. Use CMake to generate the Makefile.
# -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.
$CMAKE \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/<your_toolchain_config_path>/android.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=/<your_install_path>/dlib \
-DANDROID_NDK=/Users/<your_user_name>/Library/Android/sdk/ndk-bundle \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_ABI=armeabi-v7a \
-DANDROID_NATIVE_API_LEVEL=16 \
-DANDROID_LINKER_FLAGS="-landroid -llog" \
-DANDROID_STL=c++_shared \
-DANDROID_CPP_FEATURES="rtti exceptions" \
..
# Step 4. Build by the given generated Makefile.
$CMAKE --build .
# Step 5 (optional). Install the library.
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment