Compile boost libraries for iPhone and iPhone Simulator

Source: Internet
Author: User
1. Download boost and decompress it to/users/test/downloads/boost_000049_0.

2 CD/users/test/downloads/boost_000049_0

3. Open the terminal console, type Su, enter the administrator password, and then type VI./build. bat.

4. Enter the following content in the console:

#! /Bin/sh
# Prefix =/libs
# Echo $ {prefix}
# Ls/usr/local
Echo 'now start install boost. built'
# Cd tools/build/v2/
# Chmod + X./Bootstrap. Sh
#./Bootstrap. Sh
# B2 install -- prefix =/libs
# Downloads =/users/test/downloads/
# Sdk_version = "4.3"
#./Bjam -- With-RegEx -- toolset = Darwin architecture = x86 target-OS = iPhone define = _ little_endian link = static stage
# $ {Downloads} boost_000049_0/tools/build/v2/engine/bin. macosxx86_64/B2 -- With-RegEx -- layout = versioned -- includedir =/libs/include/-- libdir =/libs/lib/i386 -- Build-type = minimal toolset = intel-Darwin stage

#

# Compile only RegEx

#./Bootstrap. Sh -- With-libraries = RegEx

# Compile all libraries

./Bootstrap. Sh

# Compile the arm library.

./Bjam -- layout = versioned -- Build-type = complete toolset = Darwin architecture = arm target-OS = iPhone MacOSX-version = iphone-4.3 define = _ little_endian link = static debug release stage

# Compile the i386 library for Simulators

./Bjam -- layout = versioned -- Build-type = complete toolset = Darwin architecture = x86 target-OS = iPhone MacOSX-version = iphonesim-4.3 link = static debug release stage

5 Press ESC and type: WQ, that is, save and exit.

6. Type chmod + X./build. bat in the console,

7 Open/users/test/downloads/boost_1_49_0/tools/build/v2/user-config.jam in a text editor

Find # using GCC and add the following content. Note # It indicates the annotation, which means to specify the compiler and its parameters. During the test, only the compiling iphonesimulator section is enabled, the C ++ compiler used at the beginning is g ++-4.2. The code generated later may report a code generation error. I'm not sure if it is a compiler problem, I changed llvm-G ++-4.2, because the llvm-GCC compiler is used by default in xcode, so I will use it here. If I want to compile the boost that the iPhone really can run, -Arch armv7 needs to be specified

 

Using Darwin: 4.2.1 ~ IPhone
:/Developer/platforms/iphoneos. Platform/developer/usr/bin/llvm-G ++-4.2-arch armv7-mthumb-fvisibility = hidden-fvisibility-inlines-hidden
: <Striper>
: <Architecture> arm <target-OS> iPhone
;
# <MacOSX-version> iphone-4.3
Using Darwin: 4.2.1 ~ Iphonesim
:/Developer/platforms/iphonesimulator. Platform/developer/usr/bin/llvm-G ++-4.2-arch i386-fvisibility = hidden-fvisibility-inlines-hidden
: <Striper>
: <Architecture> x86 <target-OS> iPhone
;
# <MacOSX-version> iphonesim-4.3
#;

 

8 open/users/test/downloads/boost_1_49_0/tools/build/v2/tools/Darwin. jam in the text editor and add

 

# The MacOSX versions we can target.
. MacOSX-version =
10.6 10.5 10.4 10.3 10.2 10.1
Iphone-4.3 iphonesim-4.3
Iphone-3.2 iphonesim-3.2
Iphone-3.1.3 iphonesim-3.1.3
Iphone-3.1.2 iphonesim-3.1.2
Iphone-3.1 iphonesim-3.1
Iphone-3.0 iphonesim-3.0
Iphone-2.2.1 iphonesim-2.2.1
Iphone-2.2 iphonesim-2.2
Iphone-2.1 iphonesim-2.1
Iphone-2.0 iphonesim-2.0
Iphone-1.x
;

However, I think this part should be okay if it is not added,

9. Execute./build. bat in the command line. Later, you can find libboost_regex.a in/users/test/downloads/boost_1_49_0/stage.

If the following error is reported in the reference boost static library (the demo program of the debug version should reference the boost library of the debug version, the demo program of the release version should reference the boost library of the release version, otherwise, this error will occur ):

Bad codegen, pointer diff in void boost: throw_exception <STD: logic_error> (STD: logic_error const &) to global weak symbol boost: exception_detail: clone_impl <boost :: prediction_detail: error_info_injector <STD: logic_error> ::~ Clone_impl () for architecture i386

You can set the value of symbols hidden by default to yes and re-compile projects and targets build-settings-> llvm-GCC 4.2-code generation.

If the following error occurs again:

Code sign error: the identity 'iphone developer 'doesn' t match any valid CER

You can re-create a demo project and try again. I just need to re-create a project.

Reference URL:

Http://paulsolt.com/2010/04/c-logging-and-building-boost-for-iphoneipad-3-2-and-macosx/

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.