为iphone 及iphone simulator编译boost库

本文详细介绍如何在iOS环境下编译并安装Boost库,包括配置编译环境、修改配置文件等步骤,解决常见编译错误。
1 下载boost,解压到/Users/test/Downloads/boost_1_49_0

2 cd /Users/test/Downloads/boost_1_49_0

3 打开terminal控制台,键入su然后输入管理员密码,再键入vi ./build.bat

4 在控制台里录入以下内容:

 #! /bin/sh
#PREFIX=/libs
#echo ${PREFIX}
#ls /usr/local
echo 'now start install boost.build'
#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_1_49_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

#

# 只编译regex

#./bootstrap.sh --with-libraries=regex

#编译所有的库

./bootstrap.sh

# 编译arm库,真机用

./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

#编译i386库,模拟器用

./bjam --layout=versioned --build-type=complete toolset=darwin architecture=x86 target-os=iphone macosx-version=iphonesim-4.3 link=static debug release stage

5 按Esc 然后键入:wq 也就是保存退出

6 在控制台里键入chmod +x ./build.bat,

7 用文本编辑器打开/Users/test/Downloads/boost_1_49_0/tools/build/v2/user-config.jam

找到#using gcc附近,加入以下内容,注意#表示注释,意思是指定编译器及其参数,我测试时只打开了编译iphonesimulator部分,开始用的c++编译器是g++-4.2,后来生成的代码好像会报code generation错误,我也不确定是不是编译器的问题,就换了llvm-g++-4.2,因为xcode里默认用llvm-gcc编译器,所以这里先用这个,如果也要编译iphone真机能跑的boost,需要指定-arch armv7

 

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 用文本编辑器打开/Users/test/Downloads/boost_1_49_0/tools/build/v2/tools/darwin.jam,在最上方加入

 

 ## 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
    ;

不过我感觉这一块不加也应该可以,

9 在命令行里执行./build.bat,过一会可以在 /Users/test/Downloads/boost_1_49_0/stage里找到 libboost_regex.a

 如果在引用boost静态库里报以下错误(debug版本的demo程序应该引用debug版本的boost库,release版本的demo程序应该引用release版本的boost库,不然就会出现这种错误):

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::exception_detail::error_info_injector<std::logic_error> >::~clone_impl()for architecture i386

可以将projects和targets的build-settings->llvm-gcc 4.2-code generation ,将Symbols Hidden By Default的值设为yes,然后重新编译即可

如果再出现以下错误:

Code Sign error: The identity 'iPhone Developer' doesn't match any valid cer

可以重新建一个demo项目再试试看,我重新建了一个项目就好了。

参考网址:

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

转载于:https://www.cnblogs.com/yuanxiaoping_21cn_com/archive/2012/05/25/2518681.html

### 中职学校网络安全理论课程大纲和教学内容 #### 2025年中职学校网络安全理论课程概述 随着信息技术的发展网络安全已成为信息化社会的重要组成部分。为了适应这一需求,中职学校的网络安全理论课程旨在培养学生具备基本的网络安全意识和技术能力,使学生能够在未来的职业生涯中应对各种网络威胁。 #### 教学目标 该课程的目标是让学生理解网络安全的基本概念、原理和技术手段,掌握常见的安全防护措施,并能应用这些知识解决实际问题。具体来说,学生应达到以下几点: - 掌握计算机网络基础架构及其工作原理; - 理解信息安全管理体系框架及其实现方法; - 学习密码学基础知识以及加密算法的应用场景; - 能够识别常见攻击方式并采取有效防御策略; #### 主要章节安排 ##### 第一章 计算机网络与互联网协议 介绍计算机网络的基础结构和服务模型,重点讲解TCP/IP五层体系结构中的各层次功能特点,特别是传输控制协议(TCP)和用户数据报协议(UDP)[^1]。 ##### 第二章 信息系统安全保障概论 探讨信息系统的脆弱性和风险评估机制,阐述如何通过物理隔离、访问控制等措施来保障系统安全性。 ##### 第三章 密码学入门 讲述对称密钥体制和非对称密钥体制的区别与发展历程,分析公钥基础设施(PKI)的工作流程及其重要性。 ##### 第四章 防火墙技术与入侵检测系统(IDS) 解释防火墙的作用原理及其分类形式(包过滤型、代理服务器型),讨论IDS的功能特性及部署建议。 ##### 第五章 Web应用程序安全 针对Web环境下的特殊挑战展开论述,如SQL注入漏洞利用、跨站脚本(XSS)攻击防范等内容。 ##### 实践环节设置 除了上述理论部分外,在每学期还设有专门实践课时用于模拟真实环境中可能遇到的安全事件处理过程,增强学生的动手操作能力和应急响应水平。 ```python # Python代码示例:简单的MD5哈希函数实现 import hashlib def md5_hash(text): hasher = hashlib.md5() hasher.update(text.encode('utf-8')) return hasher.hexdigest() print(md5_hash("example")) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值