Skip to content

Instantly share code, notes, and snippets.

@vemarav
Last active February 18, 2024 08:38
Show Gist options
  • Save vemarav/73cb1745533d1520c588fb4c04ea6b4a to your computer and use it in GitHub Desktop.
Save vemarav/73cb1745533d1520c588fb4c04ea6b4a to your computer and use it in GitHub Desktop.
Generate ceres-solver libceres.so for android

STEP 1

git clone https://ceres-solver.googlesource.com/ceres-solver

STEP 2

cd ceres-solver
mkdir build_lib
cd build_lib
cmake ..
make
# it will print paths for google glog, eigen3, sparse etc, we will use them for android build

STEP 3

cd /path/to/ceres-solver # cloned directory
mkdir build_android_armeabi-v7a
cd build_android_armeabi-v7a
cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/Library/Android/sdk/ndk/25.1.8937393/build/cmake/android.toolchain.cmake \
    -DBUILD_SHARED_LIBS=ON \
    -DANDROID_STL=c++_shared \
    -DANDROID_ABI=armeabi-v7a \
    -DANDROID_NATIVE_API_LEVEL=android-28 \
    -DEigen3_DIR=/opt/homebrew/share/eigen3/cmake \
    -DMINIGLOG=ON \
    ..
make
# Now you can find libceres.so inside libs folder

STEP 4

cd /path/to/ceres-solver # cloned directory
mkdir build_android_arm64_v8a
cd build_android_arm64_v8a
cmake -DCMAKE_TOOLCHAIN_FILE=/Users/vemarav/Library/Android/sdk/ndk/25.1.8937393/build/cmake/android.toolchain.cmake \
    -DBUILD_SHARED_LIBS=ON \
    -DANDROID_STL=c++_shared \
    -DANDROID_ABI=arm64-v8a \
    -DANDROID_NATIVE_API_LEVEL=android-28 \
    -DEigen3_DIR=/opt/homebrew/share/eigen3/cmake \
    -DMINIGLOG=ON \
    ..
make
# Now you can find libceres.so inside libs folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment