Reprinted please indicate the source is klayge Game Engine
Boost is already common in C ++ development on PC. But what about mobile platforms like android? Because klayge is porting Android, boost, which is one of the dependent libraries, must also be transplanted. The official Boost does not provide Android support. It seems that you have to do it yourself.
Inspired by boost-for-android of mystictreegames, I want to use the latest crystax ndk to compile boost 1.47.
Preparations
Download required
- Boost 1.47
- Crystax's ndk R6
- Boost-for-android of mystictreegames
Patch
First, the patch for mystictreegames is based on boost 1.45 and the official ndk R5, which may not work perfectly in the latest version. Because some source files are changed from 1.45 to 1.47, they cannot be automatically patched. So I manually modified the patch on the original boost 1.47. In fact, it is not difficult, because only 12 files need to be modified.
Compile scripts
The build-android.sh provided by mystictreegames cannot be used directly, probably because it has not been tested on cygwin. So I wrote a build_android.sh and a build_android.bat as the compilation script. Fortunately, the final script is simple and can be used in windows, cygwin, and Linux. (Additionally, cygwin is no longer needed if build_android.bat is used !)
At this point, boost 1.47 can be compiled properly using ndk R6. However, the disadvantage is that only static libraries ("link = static runtime-link = static") can be generated ").
Can I use VC for compilation?
Then I tried VC10 to compile boost, and the result went wrong. Since the user-config.jam is patched, it now supports only ndk compilers. The solution is to copy the modified user-config.jam to the boost root directory and rename it to another name, such as the user-config-android.jam. Then you can use "bjam-user-Config =./user-config-android.jam ..." To tell bjam which. Jam is used as the user config.
Together
In the attachment, you can find all the files I have modified. Before compilation, you must set an environment variable named "android_ndk" and only want your ndk root directory.
Boost_for_android_patch.7z