【问题标题】:How can I compile Boost 1.54.0 (1.54) for the iOS simulator (6.1) on OS X 10.8.4?如何在 OS X 10.8.4 上为 iOS 模拟器 (6.1) 编译 Boost 1.54.0 (1.54)?
【发布时间】:2013-07-16 21:10:46
【问题描述】:

我已经成功地编译了几个 Boost 库,并使用此脚本创建了一个用于 OS X、iOS 和 iOS 模拟器的框架:https://github.com/wuhao5/boost/blob/188e905626dbd522f65950102ed0c8ce77cb28e8/boost.sh 基于 Peter Goodliffe 在此处的工作:http://goodliffe.blogspot.com/2010/09/building-boost-framework-for-ios-iphone.html with Boost 1.53.0 使用 clang 并链接到 libc++。

使用 Boost 1.54.0 为 iOS 模拟器编译时脚本失败,并出现以下错误:/bin/sh: line 1: -ftemplate-depth-128: command not found。

我做了很多挖掘,以下是我所知道的:

  • 在 boost.sh 中,iOS 模拟器 bjam 和编译器选项包括“-arch i386”
  • Boost 1.54.0 的发行说明指出“Boost 不再支持 80386 目标 CPU”
  • Boost 1.53.0 似乎可以使用相同的脚本为 OS X、iOS 和 iOS 模拟器正常编译
  • Boost 1.54.0 似乎可以使用相同的脚本为 OS X 和 iOS 本身编译良好​​li>

以下是我认为我知道的:

  • 将“-d13”传递给 bjam(以生成调试信息)时,在为 iOS 模拟器构建时,似乎没有设置变量“CONFIG_COMMAND”。对于其他配置,此变量设置为 clang 的路径并包括编译器选项。对于模拟器,它是空的,我认为这会导致上述错误,因为当 bjam 尝试使用此变量运行编译器时,它会运行一些以模板深度开头的附加选项。因此,CONFIG_COMMAND 变量似乎没有正确设置,导致失败。

我不知道为什么没有设置它,因为我对 Boost 构建系统了解不足,无法筛选它使用“-d13”标志生成的其余 100+MB 输出。我怀疑在 1.54.0 中引入了与“-arch i386”选项不兼容的问题。我尝试将其更改为“-arch i486”和“-arch x86_32”,但出现了同样的问题。

还有其他人在这方面取得成功吗?我想使用 Boost.Log,这就是我什至尝试这样做的原因。

【问题讨论】:

  • 我和你在同一条船上,我想知道你或其他人是否最终解决了这个问题。据我所知,“-ftemplate-depth-128: command not found”可能是编译器空白替换的结果,如下所示: ${COMPILER} -ftemplate-depth-128 这就是为什么该错误使 ftemplate-depth-128 听起来像是一个命令。
  • 很遗憾,我还没有找到解决方案。我相信编译器命令应该设置在 ${CONFIG_COMMAND} 中。对于 iOS 构建的实际设备行,调试输出中会出现这样的情况:toolset.handle-flag-value /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++,紧随其后的是:get .darwin.variable.295 = CONFIG_COMMAND。
  • 您使用的是哪个版本的 XCode?​​span>
  • 我使用的是 Xcode 4.6.3

标签: c++ ios boost c++11 clang


【解决方案1】:

我通过更改 buildBoostForiPhoneOS() 中的行来使用此处给出的 boost.sh 构建它

./bjam -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage --toolset=darwin architecture=x86 target-os=iphone macosx-version=iphonesim-${IPHONE_SDKVERSION} link=static stage

到

./bjam -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage --toolset=darwin-${IPHONE_SDKVERSION}~iphonesim architecture=x86 target-os=iphone macosx-version=iphonesim-${IPHONE_SDKVERSION} link=static stage

修改 boost.sh 并使用 Boost pkg 下载和解包。只需要运行就完成了!

Boost 1.54
MacOSx 10.8.4
Xcode 4.6.3

【讨论】:

  • 谢谢!那是为我做的!
  • 好的,只是想帮助解决问题:stackoverflow.com/questions/18888327/… 但我在 OSX 10.8 下使用 Xcode 5 DP6 时遇到以下错误:boost.sh: line 252: /Users/andy/Applications/Xcode5-DP6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin//ar: No such file or directory。知道如何解决这个问题吗?
  • @trojanfoe 我在第一次运行 boost.sh 后遇到了同样的问题。以下似乎对我有所帮助(因为我的机器现在正忙于构建代码而不是挂在 lipo 调用上):cd to {generated src dir}/boost_1_54_0/ Run ./bootstrap.sh toolset=clang Rerun boost.sh
  • 这是更改的要点。似乎对我有用。 gist.github.com/payco/6880661 我现在在整个标准库中都遇到了语义问题,但我认为这是决定不使用 c++11 编译 libc++ 头文件的原因。
  • 伟大的工作。我也扩展了 @matthias 的脚本以构建 arm64 和 x86_64。要点如下:gist.github.com/rsobik/7513324
【解决方案2】:

我不久前通过阅读 boost 1.53.0 和 1.54.0 之间的每个 jam 文件的差异来解决这个问题,这是一项艰巨的任务。本来想发补丁的,但是找原因花了我没有的时间,现在我不记得是什么了。

无论如何,我确实记得我过去常常在最后期限前完成的快速解决方案。对于 boost 1.54.0,为 bjam 提供“toolset=darwin-[version]~iphonesim”参数。你也可以给 arm builds toolset=darwin-[version]~iphone,虽然它不需要它。

例如,使用 iOS 6.1 SDK:

./b2 toolset=darwin-6.1~iphonesim architecture=x86 target-os=iphone macosx-version=iphonesim-6.1 link=static variant=debug  define=BOOST_TEST_NO_MAIN define=BOOST_TEST_ALTERNATIVE_INIT_API linkflags="-stdlib=libc++" -j2 -d+2 -sICU_PATH=/usr/local/icu --without-python --layout=tagged --build-dir="/Users/wix/Desktop/boost_1_54_0/_build/simd_build" --stagedir="/Users/wix/Desktop/boost_1_54_0/_build/simd_stage" --debug-configuration stage

如果这对您不起作用,请告诉我,如果我有时间,我会从备份中获取旧的构建目录,看看我是否还有其他操作。上面的命令来自我的 histfile。

另外,仅供参考,要使仅针对 v7 和 v7s 且 ICU 库同样构建的 arm 构建通过 ICU 检查,请将以下补丁应用于 tools/build/v2/tools/darwin.jam:

460,464c460,465
<             if $(instruction-set) {
<                 options = -arch$(_)$(instruction-set) ;
<             } else {
<                 options = -arch arm ;
<             }
---
>             #if $(instruction-set) {
>             #    options = -arch$(_)$(instruction-set) ;
>             #} else {
>             #    options = -arch arm ;
>             #}
>       options = -arch armv7 ;

此外,更一般地说,您的 ~/user-config.jam 中可能需要以下内容:

using clang : : : <cxxflags>"-std=c++11 -stdlib=libc++" <linkflags>"-stdlib=libc++" ;

using darwin : 6.1~iphone
   : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch armv7 -arch armv7s -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -stdlib=libc++ -miphoneos-version-min=5.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
   : <striper> <root>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
   : <architecture>arm <target-os>iphone
   ;

using darwin : 6.1~iphonesim
   : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -stdlib=libc++ -miphoneos-version-min=5.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk
   : <striper> <root>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
   : <architecture>x86 <target-os>iphone
   ;

另外,为了为模拟器正确构建 boost::context,我需要将以下内容添加到 libs/context/build/Jamfile.v2:

alias asm_context_sources
   : asm/make_i386_sysv_macho_gas.S
     asm/jump_i386_sysv_macho_gas.S
   : <address-model>32
     <architecture>x86
     <binary-format>mach-o
     <target-os>iphone
     <toolset>darwin
   ;

【讨论】:

  • 我有兴趣了解更多。您发布的对 b2 参数的更改是否会创建一个像提到的脚本一样的 .framework 文件?
  • Erik,你的 b2 参数我无法为 i386 架构构建,今天刚刚使用 boost 1.54 进行了测试。
  • tetuje,我建议在您的 ~/user-config.jam 中尝试以下内容:(此处空间不足,请查看我上面的编辑)
  • Aldrich Co,我的论点没有构成框架。我认为制作框架主要是将所有 boost 头文件和库放在目录结构中的正确位置并合并库。由于 b2 创建的一些单独的 .a 文件包含同名的目标文件,因此合并库有点棘手;合并时需要重命名重复项...请注意,上面发布的 .sh 文件不会这样做,如果您需要 codecvt,则会出现问题。我最终编写了一个 python 脚本来解决这个问题。如果你需要,我看看能不能分享(我是在工作中写的)。
【解决方案3】:

根据这篇文章中的回复和其他人创建的脚本,我整理了一个 bash 脚本,该脚本使用 Xcode 5 为 iOS 和 OSX 构建了 boost 框架,这意味着 armv7、armv7s、arm64、i386 和 x86_64。

在这里查看https://github.com/mgrebenets/boost-xcode5-iosx。

我确信它会从 1.49.0 开始构建提升

【讨论】:

  • 谢谢!但似乎我遇到了一些问题(从 bjam 输出中提取的命令): g++ -x assembler-with-cpp -arch armv7 -o make_arm_aapcs_macho_gas.o -c make_arm_aapcs_macho_gas.S 以上似乎工作,但 g++ -x assembler-with- cpp -arch arm64 -o make_arm_aapcs_macho_gas.o -c make_arm_aapcs_macho_gas.S 只是不编译:make_arm_aapcs_macho_gas.S:52:18: 错误:无效变体 'save' mov a4, a1 @ 上下文堆栈的保存地址(基础)A4 任何洞察力?
【解决方案4】:

对于那些有兴趣保持最新的人:

您可以将 BOOST 1.57.0 与 ofxiOSBoost 静态库和头文件一起使用: https://github.com/danoli3/ofxiOSBoost

针对 libc++ (c++11)、libstdc++ 的版本。

所有构建脚本都在 /scripts 文件夹中(更新的 Peter Goodliffe 脚本)

【讨论】:

  • 我有兴趣了解框架的最新动态。
猜你喜欢
  • 2013-06-02
  • 2011-11-03
  • 2013-06-30
  • 2014-09-14
  • 2014-07-02
  • 2013-09-15
  • 1970-01-01
  • 2015-02-22
相关资源
最近更新 更多