C++ Logging and building Boost for iPhone/iPad 3.2 and MacOSX

本文详细介绍如何为iPhone设备和模拟器构建Boost库,并介绍如何在Xcode项目中设置这些库。此外,还提供了针对MacOSX的四合一通用版本构建指南。
  1. Get Boost 1.42
  2. Extract Boost:
    tar xzf boost_1_42_0.tar.gz
  3. Create a user-config.jam file in your user directory (~/user-config.jam) such as /Users/paulsolt/user-config.jam with the following. (Note:  this config file needs to be rename or moved during the MacOSX bjam build)



    ~/user-config.jam

    using darwin : 4.2.1~iphone
       : /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv7 -mthumb -fvisibility=hidden -fvisibility-inlines-hidden
       : <striper>
       : <architecture>arm <target-os>iphone <macosx-version>iphone-3.2
       ;
     
    using darwin : 4.2.1~iphonesim
       : /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden
       : <striper>
       : <architecture>x86 <target-os>iphone <macosx-version>iphonesim-3.2
       ;
  4. Make sure the file boost_1_42_0/tools/build/v2/tools/darwin.jam has the following information:
    tools/build/v2/tools/darwin.jam
    ## The MacOSX versions we can target.
    .macosx-versions =
        10.6 10.5 10.4 10.3 10.2 10.1
        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
        ;
  5. Change directories to the Boost directory that you downloaded:
    cd /path/to/boost_1_42_0
  6. Run the following commands to compile the iPhone and iPhone Simulator Boost libraries. I only need filesystem, system, and thread to be use Boost logging for the iPhone, so I don’t build everything. Run ./bootstrap.sh –help or ./bjam –help for more options. I built the binaries to a location in my development folder to include in my project dependencies.


    ./bootstrap.sh --with-libraries=filesystem,system,thread


    ./bjam --prefix=${HOME}/dev/boost/iphone toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-3.2 define=_LITTLE_ENDIAN link=static install
    ./bjam --prefix=${HOME}/dev/boost/iphoneSimulator toolset=darwin architecture=x86 target-os=iphone macosx-version=iphonesim-3.2 link=static install
  7. Update: Create a universal Boost Library using the lipo tool. In this example I’m assuming the binaries that were created have the following names. The names from the bjam generation will be different, based on your own configuration.End Update


    lipo -create libboost_filesystem_iphone.a libboost_filesystem_iphonesimulator.a -output libboost_filesystem_iphone_universal.a
     
    lipo -create libboost_system_iphone.a libboost_system_iphonesimulator.a -output libboost_system_iphone_universal.a
     
    lipo -create libboost_thread_iphone.a libboost_thread_iphonesimulator.a -output libboost_thread_iphone_universal.a
  8. I’m working on a cross-platform project and my directory structure looks like the following structure. I copied the include and lib files for iPhone and iPhone Simulator into the appropriate directories. The dependency structure allows me to checkout the project on another machine and have relative references to Boost and other dependencies.
       |-ArtworkEvolution
       |---Xcode
       |-----BoostLoggingTest
       |---dependencies
       |-----iphone
       |-------debug
       |-------release
       |---------include
       |-----------boost
       |---------lib
       |-----iphone-simulator
       |-------debug
       |-------release
       |---------include
       |-----------boost
       |---------lib
       |-----macosx
       |-------debug
       |-------release
       |---------include
       |-----------boost
       |-----------libs
       |-----win32
       |---docs
       |---source
       |---tests
  9. Download the Boost Logging Library v2 and unzip it.
  10. Copy and paste the logging folder into each include/boost folder for iPhone and iPhone Simulator dependency folders like in my directory structure. After you unzip the header files are located in the folder logging/boost/logging.
Step 2:  Creating the Xcode Project

With the iPhone and iPhone Simulator Boost libraries in hand we’re ready to make an Xcode project. Due to the difference in the iPhone and iPhone Simulator libraries we’ll need to make two targets. One will build linking against the iPhone Boost libraries (arm) and the other against the iPhone Boost Simulator libraries (x86).

Update: You don’t need to create two targets, as we can use the lipo tool to make a universal iPhone/iPhone Simulator library file. The universal library file can be shared between iPhone and iPhone Simulator build configurations. See the instructions for using lipo to create the universal library files in the previous section. However, I will keep the two target instructions up as an alternate approach for Xcode project development, if you choose not to use the lipo tool.

End Update

1. Create a new iPhone project (view based)

2. There will be two targets: “BoostLoggingTest Device” and “BoostLogging Test Simulator” each will reference different headers and libraries. Duplicate the starting target and rename each target respectively.

Duplicate target to make iPhone/iPhoneSimulator targets

3. Add the libraries that we compiled into two groups: device and simulator under Resources. Right-click on the group “Simulator” or “Device” and select “Add Existing Files”. Search for the library .a files that you copied into the iphone and iphone-simulator directories. These resources should be added relative to the project folder.

4. Drag the appropriate libraries to each Target. We need two targets since the architecture is different on the iPhone device (arm) versus the iPhone Simulator (Intel x86).

Drag the device libraries to the device target.

Drag simulator dependencies to the iPhone simulator target

5. Add the “Header Search Path” for each target. For me the relative path will be two directories up from the Xcode project folders:  ../../dependencies/iphone/release/includeand ../../dependencies/iphone-simulator/release/include. Right-click on each Target in the left pane and click on “Get Info” -> Build -> Type “Header” in the search field -> Edit the list of paths.

Add the Device Target Header Search path for the boost libraries

Add the simulator targets Header Search Paths

6. Change the base SDK of each target. For the Device you need to use iPhone Device 3.2and the Simulator Target needs iPhone Simulator 3.2 or later.

Set the Device Target to iPhone Device 3.2

Set the Simulator Target to iPhone Simulator 3.2

7. Now you have two different targets. One is for the iPhone Device and the other is for the iPhone Simulator. We did this because we built separate binaries for Boost on the iPhone (arm) and simulator (x86) platforms.

8. Set the project’s Active SDK to use the Base SDK (top left of Xcode). Now it will automatically choose the iPhone Device or iPhone Simulator based on the Base SDK of each Target you select.

9. Logging on the iPhone requires that we use the full path to the file within the application sandbox. Use the following Objective-C code to get it:

NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [docsDirectory stringByAppendingPathComponent:@"err.txt"];
const char *outputFilename = [path UTF8String];

10. I modified one of the Boost Logging samples to use the full file path on the iPhone. Rename the main.m as main.mm to use Objective-C/C++ and copy paste the following:  main.mm code

11. If everything compiled and ran on the Device you can get the application data from the Xcode Organizer (Option+Command+O) Navigate to Devices and then look in Applications for the test application. Just drag the “Application Data” to your desktop to download it from the device. Your logs should appear in the Documents folder.

Part 3: Build Boost for Mac OS X 10.6 – 4 way fat (32/64 PPC and 32/64 Intel)

1. Build boost for Mac OS X. Note:  If you setup the user-config.jam file for iPhone Boost build, rename or move the file to a different folder than your home directory, otherwise ignore this command.

mv ~/user-config.jam ~/user-config.jam.INACTIVE
cd /path/to/boost_1_42_0
./bootstrap.sh --with-libraries=filesystem,system,thread
./bjam --prefix=${HOME}/dev/boost/macosx toolset=darwin architecture=combined address-model=32_64 link=static install

2. Copy the output into your dependency structure and add the Boost Logging Library headers into the include/boost folder. (Same procedure as with iPhone)

3. Setup a Xcode project or target with the appropriate header search path, Boost Mac OSX libraries in the same way we setup the iPhone Xcode project.

Note: If you get warnings about hidden symbols and default settings open the Xcode project for and make sure that the “Inline Methods Hidden” and “Symbols Hidden by Default” are unchecked. Clicking on/off might fix any Xcode warnings.


标题基于Python的自主学习系统后端设计与实现AI更换标题第1章引言介绍自主学习系统的研究背景、意义、现状以及本文的研究方法和创新点。1.1研究背景与意义阐述自主学习系统在教育技术领域的重要性和应用价值。1.2国内外研究现状分析国内外在自主学习系统后端技术方面的研究进展。1.3研究方法与创新点概述本文采用Python技术栈的设计方法和系统创新点。第2章相关理论与技术总结自主学习系统后端开发的相关理论和技术基础。2.1自主学习系统理论阐述自主学习系统的定义、特征和理论基础。2.2Python后端技术栈介绍DjangoFlask等Python后端框架及其适用场景。2.3数据库技术讨论关系型和非关系型数据库在系统中的应用方案。第3章系统设计与实现详细介绍自主学习系统后端的设计方案和实现过程。3.1系统架构设计提出基于微服务的系统架构设计方案。3.2核心模块设计详细说明用户管理、学习资源管理、进度跟踪等核心模块设计。3.3关键技术实现阐述个性化推荐算法、学习行为分析等关键技术的实现。第4章系统测试与评估对系统进行功能测试和性能评估。4.1测试环境与方法介绍测试环境配置和采用的测试方法。4.2功能测试结果展示各功能模块的测试结果和问题修复情况。4.3性能评估分析分析系统在高并发等场景下的性能表现。第5章结论与展望总结研究成果并提出未来改进方向。5.1研究结论概括系统设计的主要成果和技术创新。5.2未来展望指出系统局限性并提出后续优化方向。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值