Skip to content

Instantly share code, notes, and snippets.

@emmasteimann
Forked from johndpope/build.sh
Created June 10, 2021 10:50
Show Gist options
  • Save emmasteimann/ea3c6ab14cf77fa1ff33765f6b1485f6 to your computer and use it in GitHub Desktop.
Save emmasteimann/ea3c6ab14cf77fa1ff33765f6b1485f6 to your computer and use it in GitHub Desktop.
libceres.a universal build
#!/bin/bash
#brew install eigen3
EIGEN_PATH=/opt/local/include/eigen3
# build for device
cmake . -DCMAKE_TOOLCHAIN_FILE=./cmake/iOS.cmake -DEIGEN_INCLUDE_DIR=${EIGEN_PATH} -DIOS_PLATFORM=OS -DEIGENSPARSE=ON
make -j8
# install headers in ..
make install
# delete the installed lib (we want a universal one)
rm ../lib/libceres.a
# build for simulator
cmake . -DCMAKE_TOOLCHAIN_FILE=./cmake/iOS.cmake -DEIGEN_INCLUDE_DIR=${EIGEN_PATH} -DEIGENSPARSE=ON -DIOS_PLATFORM=SIMULATOR
make -j8
mkdir -p build_simulator
cp ./lib/libceres.a ./build_simulator
# build for simulator64
cmake . -DCMAKE_TOOLCHAIN_FILE=./cmake/iOS.cmake -DEIGEN_INCLUDE_DIR=${EIGEN_PATH} -DEIGENSPARSE=ON -DIOS_PLATFORM=SIMULATOR64
make -j8
mkdir -p build_simulator64
cp ./lib/libceres.a ./build_simulator64
# create universal library
lipo -create build/ build_simulator/lib/libceres.a build_simulator64/lib/libceres.a -output lib/libceres-universal.a
# clean up
#rm -rf build build_simulator build_simulator64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment