NDK compiles Boost (Cygwin environment), ndk compiles boostcygwin

Source: Internet
Author: User

NDK compiles Boost (Cygwin environment), ndk compiles boostcygwin

Because mapnik requires support from some Boost modules, it is necessary to compile the Boost library. It is not difficult to compile Boost directly in Windows or Linux. Several commands can be done, but for cross-compilation, as described in this article, using NDK for compilation is indeed a headache. With the help of the omnipotent Google and Baidu, I sorted out the methods and conducted a test.

However, before that, I want to clarify a misunderstanding and make up a lesson for myself. That is, not all Boost libraries need to be compiled when they are used. A small part of platform-related modules must be compiled. Most of them can be used directly by referencing header files. After all, Boost is too huge, and all compilation is a waste of time. It is best to use it as needed. The following is an excerpt from the Boost official website. I will not translate it here. This word is not a problem for coders.

The only Boost libraries thatMustBe built separately are:

  • Boost. Chrono
  • Boost. Context
  • Boost. Filesystem
  • Boost. GraphParallel
  • Boost. IOStreams
  • Boost. Locale
  • Boost. MPI
  • Boost. ProgramOptions
  • Boost. Python (see the Boost. Python build documentation before building and installing it)
  • Boost. Regex
  • Boost. Serialization
  • Boost. Signals
  • Boost. System
  • Boost. Thread
  • Boost. Timer
  • Boost. Wave

A few libraries have optional separately-compiled binaries:

  • Boost. DateTime has a binary component that is only needed if you're using itsTo_string/From_stringOr serialization features, or if you're targeting Visual C ++ 6.x or Borland.
  • Boost. Graph also has a binary component that is only needed if you intend to parse GraphViz files.
  • Boost. Math has binary components for the TR1 and C99 cmath functions.
  • Boost. Random has a binary component which is only needed if you're usingRandom_device.
  • Boost. Test can be used in "header-only" or "separately compiled" mode, althoughSeparate compilation is recommended for serious use.
  • Boost. exception provides non-intrusive implementation of prediction_ptr for 32-bit _ MSC_VER = 1310 and _ MSC_VER = 1400 which requires a separately-compiled binary. this is enabled by # define BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR.

Next we will introduce the compilation steps. I used NDK for compiling in Windows, so I chose the Cygwin environment. The methods in Linux alone are similar.

NDK version: Official R10c

Boost versions: 1.57

1. Download boost_000057_0.tar.gz and put it in the Cygwin virtual Linux directory, such as/usr /.

2. Open Cygwin and use the tar zxvfcommand to decompress boost_000057_0.tar.gz.

3. cd to the decompressed Boost root directory, run./bootstrap. sh to generate the boost compilation tool.

4. Open the project-config.jam file in the root directory with a text editor and modify it to the following:

Import OS; if [OS. name] = CYGWIN | [OS. name] = NT {androidPlatform = windows;} else if [OS. name] = LINUX {androidPlatform = linux-x86_64;} else if [OS. name] = MACOSX {androidPlatform = darwin-x86;} ANDROID_NDK = <actual NDK path>; using gcc: android4.9: $ (ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$ (androidPlatform) /bin/arm-linux-androideabi-g ++: <archiver >$ (ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$ (androidPlatform) /bin/arm-linux-androideabi-ar <ranlib> $ (ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$ (androidPlatform) /bin/arm-linux-androideabi-ranlib <compileflags>-I $ (ANDROID_NDK) /platforms/android-19/arch-arm/usr/include <compileflags>-I $ (ANDROID_NDK) /sources/cxx-stl/gnu-libstdc ++/4.9/include <compileflags>-I $ (ANDROID_NDK) /sources/cxx-stl/gnu-libstdc ++/4.9/libs/armeabi/include <compileflags>-fexceptions <compileflags>-frtti <compileflags>-fpic <compileflags>-ffunction -sections <compileflags>-funwind-tables <compileflags>-d1_arm_arch_5 __< compileflags>-example __< compileflags>-Wno-psabi <compileflags>-march = armv5te <compileflags>-mtune = xscale <compileflags>-msoft-float <compileflags>-balance <compileflags>-OS <compileflags>-fomit-frame-pointer <compileflags>-fno-strict-aliasing <compileflags>-finline-limit = 64 <compileflags>-Wa, -- noexecstack <compileflags>-DANDROID <compileflags>-d1_android __< compileflags>-DNDEBUG <compileflags>-O2 <compileflags>-g; project: default-build <toolset> gcc-android4.9; # List of -- with-<library> and -- without-<library> # options. if left empty, all libraries will be built. # Options specified on the command line completely # override this variable. libraries = -- with-filesystem -- with-thread -- with-system -- with-regex -- with-program_options;

Enter the NDK path based on the actual situation, and modify the gcc version based on the actual situation. Libraries is followed by the Boost module to be compiled.

Ps: There are some differences between this step and the method circulating on the Internet, according to its statement is "Modify boost/tools/build/v2/user-config.jam", but the actual Boost1.57 does not generate this file, it is suspected that Boost has modified Bjam in the new version.

5. Execute./b2 toolset = gcc-android4.9 link = static threading = multi target-OS = linux -- stagedir = android, -- stagedir and the generated path.

 

At this point, the compiled Boost module is generated. The fourth step of the Code is that I have integrated the code on the Internet and the code in an open-source project Boost for Android. There are many compilation options that I do not understand very well. I hope I can communicate with you. However, it can be ensured that the compilation is successful.

By the way, mapnik is really difficult to configure. It took me a long time to make it usable, because it requires support from too many other libraries, especially on Android, cross-compilation is required. I will sort it out one by one when I have time, and I hope that friends who are interested can communicate with each other.

  

 

 

   

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.