[준비물]
- boost for Android의 git repository의 파일들
. https://github.com/MysticTreeGames/Boost-for-Android
. git clone 해서 받아도 되고 귀찮으면 zip으로 한꺼번에 받아도 되고
- boost source code, Android NDK
. boost source code는 boost for Android가 다운로드 받아 준다.
. Android NDK : http://developer.android.com/tools/sdk/ndk/index.html#Installing
[boost for android 실행 (Boost source code 다운로드 및 빌드)]
1. boost for build에 명시되어 있는 표에 맞춰서 Andorid NDK 다운로드
Boost for Android
Boost for android is a set of tools to compile the main part of the Boost C++ Libraries for the Android platform.Currently supported boost versions are 1.45.0, 1.48.0, 1.49.0 and 1.53.0.To compile Boost for Android you may use one of the following NDKs:
|
* Android NDK 32bit version 사용 필요, build for boost가 인식 못함.
. Android NDK의 RELEASE.txt에서 64bit description을 제거해도 toolchaing등이 32bit에 맞춰 설정 되어 있음.
2. build-android 실행
* 다운받은 build for andoid 내 build-android.sh 실행
. option들 중에는 boost version을 정하는 --boost, 빌드 대상 library를 정하는 --with[out]-libraries 가 있음.
haha@cs-portable:~/source/Boost-for-Android$ ./build-android.sh --help
Usage: build-android.sh [options] <ndk-root>
Boost For Android
Copyright (C) 2010 Mystic Tree Games
Valid options (defaults are in brackets):
--help Print this help.
--verbose Enable verbose mode.
--output=<path> Specify specific log output path (only terminal output by default)
--boost=<version> Boost version to be used, one of {1.53.0,1.49.0, 1.48.0, 1.45.0}, default is 1.53.0.
--clean Delete all previously downloaded and built files, then exit.
--download Only download required files and clean up previus build. No build will be performed.
--with-libraries=<list> Comma separated list of libraries to build.
--without-libraries=<list> Comma separated list of libraries to exclude from the build.
haha@cs-portable:~/source/Boost-for-Android$ ./build-android.sh
To follow build in another terminal, please use: tail -F /home/haha/source/Boost-for-Android/logs/myst-log-14385.log
Building boost version: 1.53.0
Using AndroidNDKRoot = /home/haha/_program/android-ndk-r8e
Detected Android NDK version 8e
Building with TOOLSET=gcc-androidR8e CXXPATH=/home/haha/_program/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ CXXFLAGS= -L -L -lgcc
Downloading boost 1.53.0 please wait...
--2013-03-27 01:15:09-- http://downloads.sourceforge.net/project/boost/boost/1.53.0/boost_1_53_0.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fboost%2Ffiles%2Fboost%2F1.53.0%2F&ts=1291326673&use_mirror=garr
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://garr.dl.sourceforge.net/project/boost/boost/1.53.0/boost_1_53_0.tar.bz2 [following]
--2013-03-27 01:15:09-- http://garr.dl.sourceforge.net/project/boost/boost/1.53.0/boost_1_53_0.tar.bz2
Resolving garr.dl.sourceforge.net (garr.dl.sourceforge.net)... 193.206.140.34, 2001:760:ffff:b0::34
Connecting to garr.dl.sourceforge.net (garr.dl.sourceforge.net)|193.206.140.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 55765258 (53M) [application/octet-stream]
Saving to: `/home/haha/source/Boost-for-Android/boost_1_53_0.tar.bz2'
0K .......... .......... .......... .......... .......... 0% 46.5K 19m30s
50K .......... .......... .......... .......... .......... 0% 71.2K 16m6s
|
* 기본으로는 static library로 빌드가 되며 아래 메세지가 나와도 library들 빌드와 header 복사는 된 상태 임
. "./build-android.sh: 318: ./build-android.sh: Bad substitution"
* 몇건은 실패하는데.. 사실 system, filesystem, thread, date_time 정도만 있어도 문제는 없어서..
혹시나 더 필요하다면 좀 찾아봐야 하는데.. 귀찮음..
* 생성된 libraries는 JNI project에서 추가하여 사용하면 되고 만약 so를 사용할 것이라면 Android phone에 deploy하는 것을 확인해야 함.
...skipped <p../build/lib>libboost_thread-gcc-mt-1_53.so.1.53.0 for lack of <pbin.v2/libs/thread/build/gcc-androidR8e/release/threading-multi>libboost_thread-gcc-mt-1_53.so.1.53.0...
...skipped <p../build/lib>libboost_thread-gcc-mt-1_53.so for lack of <p../build/lib>libboost_thread-gcc-mt-1_53.so.1.53.0...
...failed updating 6 targets...
...skipped 18 targets...
...updated 10251 targets...
./build-android.sh: 328: ./build-android.sh: Bad substitution
Done!
haha@cs-portable:~/source/Boost-for-Android$ find . -name *.a*
./build/lib/libboost_date_time-gcc-mt-1_53.a
./build/lib/libboost_regex-gcc-mt-1_53.a
./build/lib/libboost_iostreams-gcc-mt-1_53.a
./build/lib/libboost_thread-gcc-mt-1_53.a
./build/lib/libboost_filesystem-gcc-mt-1_53.a
./build/lib/libboost_system-gcc-mt-1_53.a
./build/lib/libboost_program_options-gcc-mt-1_53.a
./build/lib/libboost_signals-gcc-mt-1_53.a
|
[Android NDK를 사용한 Native 개발 시 참고]
* Android NDK 버전 마다 C++ library의 버전 차이로 인한 이슈 존재
Native에서 고급? C++ feature를 사용하는 경우.. 상용화 입장에서는 고생 함.
참고로 boost는 주 빌드 방법은 Android NDK + GNU_STL을 사용하고 RTTI, EXCEPTION feature는 제외하고 컴파일 함.
* NDK에서 지원하는 C++ library들의 조합은 다음과 같다.
system - Use the default minimal system C++ runtime library.
gabi++_static - Use the GAbi++ runtime as a static library.
gabi++_shared - Use the GAbi++ runtime as a shared library.
stlport_static - Use the STLport runtime as a static library.
stlport_shared - Use the STLport runtime as a shared library.
gnustl_static - Use the GNU STL as a static library.
gnustl_shared - Use the GNU STL as a shared library.
The capabilities of the various runtimes vary. See this table:
C++ C++ Standard
Exceptions RTTI Library
system no no no
gabi++ yes yes no
stlport yes yes yes
gnustl yes yes yes
. $ANDROID_NDK/doc 내 파일들 참고
: CPLUSPLUS-SUPPORT.html NDK-BUILD.html NDK-GDB.html NDK-STACK.html
* 팀원들의 NDK의 버전을 통일하는 것이 혹시나 모를 이상항 링크 에러 등을 방지하는데 도움
* Native library들을 빌드하는 NDK 버전과 Native library들이 사용하는 다른 native library들을 빌드한 NDK 버전을 통일하는 것을 추천
* JNI 빌드할때 모든 빌드 결과물의 arm, thumb mode를 맞춰라. 안 맞을 경우 원인 모를 crash 발생 가능하다.