Use Android ndk R6 to compile boost 1.47

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.