Skip to content

Instantly share code, notes, and snippets.

@deltheil
Created October 4, 2012 20:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deltheil/3836406 to your computer and use it in GitHub Desktop.
Save deltheil/3836406 to your computer and use it in GitHub Desktop.
Android NDK advanced example: build msgpack w/ the Standalone Toolchain
export NDK=/tmp/android-ndk-r8b
# 1. Use the tools from the Standalone Toolchain
export PATH=/tmp/my-android-toolchain/bin:$PATH
export SYSROOT=/tmp/my-android-toolchain/sysroot
export CC="arm-linux-androideabi-gcc --sysroot $SYSROOT"
export CXX="arm-linux-androideabi-g++ --sysroot $SYSROOT"
export CXXSTL=$NDK/sources/cxx-stl/gnu-libstdc++/4.6
# 2. Clone the Github repo and run the bootstrap actions
git clone git://github.com/msgpack/msgpack.git; cd msgpack/cpp
./preprocess
./bootstrap
mkdir build
# 3. Run the configure to target a static library for the ARMv7 ABI
./configure --prefix=$(pwd)/build \
--host=arm-linux-androideabi \
--disable-shared \
CFLAGS="-march=armv7-a" \
CXXFLAGS="-march=armv7-a -I$CXXSTL/include -I$CXXSTL/libs/armeabi-v7a/include"
# 4. Build
make && make install
# 5. Inspect the library architecture specific information
arm-linux-androideabi-readelf -A build/lib/libmsgpack.a
# File: lib/lib/libmsgpack.a(unpack.o)
# Attribute Section: aeabi
# File Attributes
# Tag_CPU_name: "7-A"
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment