为在 armv7s 上运行的 iOS 设备编译 Boost c++ 库
Posted
技术标签:
【中文标题】为在 armv7s 上运行的 iOS 设备编译 Boost c++ 库【英文标题】:Complie Boost c++ library for iOS devices running on armv7s 【发布时间】:2013-05-24 16:46:52 【问题描述】:我已经成功地在 armv6 和 armv7 上为 iPhone/iPad 构建了 boost c++ 1_44_0 库,但我似乎无法为在 armv7s 上运行的较新设备创建构建。
在 Github 上使用 BoostOnIphone 和 A-coding 来创建构建,我只需要 Boost:armv7s 架构上的线程、文件系统和系统库。
错误输出:
ld: warning: ignoring file /Users/shams/Documents/Sources/Hawk.framework/Release-iphonesimulator/libhawk-engine.a, file was built for archive which is not the architecture being linked (armv7s): /Users/shams/Documents/Sources/Hawk.framework/Release-iphonesimulator/libhawk-engine.ald: warning:
ld: warning: ignoring file /Users/shams/Documents/Sources/Hawk.framework/Release-iphoneos/libhawk-engine.a, file was built for archive which is not the architecture being linked (armv7s): /Users/shams/Documents/Sources/Hawk.framework/Release-iphoneos/libhawk-engine.ald: warning: ignoring file /Users/shams/Documents/Sources/boost.framework/Release-iphonesimulator/libboost_filesystem.a, file was built for archive which is not the architecture being linked (armv7s): /Users/shams/Documents/Sources/boost.framework/Release-iphonesimulator/libboost_filesystem.a
ignoring file /Users/shams/Documents/Sources/boost.framework/Release-iphonesimulator/libboost_system.a, file was built for archive which is not the architecture being linked (armv7s): /Users/shams/Documents/Sources/boost.framework/Release-iphonesimulator/libboost_system.a
ld: warning:
ld: warning: ignoring file /Users/shams/Documents/Sources/boost.framework/Release-iphonesimulator/libboost_thread.a, file was built for archive which is not the architecture being linked (armv7s): /Users/shams/Documents/Sources/boost.framework/Release-iphonesimulator/libboost_thread.ald: warning: ignoring file /Users/shams/Downloads/boostoniphone-master/build/armv7/libboost_filesystem.a, file was built for archive which is not the architecture being linked (armv7s): /Users/shams/Downloads/boostoniphone-master/build/armv7/libboost_filesystem.a
ignoring file /Users/shams/Downloads/boostoniphone-master/build/armv7/libboost_system.a, file was built for archive which is not the architecture being linked (armv7s): /Users/shams/Downloads/boostoniphone-master/build/armv7/libboost_system.a
ld: warning:
ignoring file /Users/shams/Downloads/boostoniphone-master/build/armv7/libboost_thread.a, file was built for archive which is not the architecture being linked (armv7s): /Users/shams/Downloads/boostoniphone-master/build/armv7/libboost_thread.a
Undefined symbols for architecture armv7s:
【问题讨论】:
您为 armv7 构建时使用了哪些编译器标志?尝试不设置任何-arch
- IIRC,它对我有用。
错误提示找不到架构
【参考方案1】:
我的解决方案是使用终端验证库架构:
otool -h libraryFile.a
输出:
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
0xfeedface 12 9 0x00 1 3 1588 0x00002000
cputype 和 cpusubtype 是要查找的值:
对于 armv7:
cpu 类型:12 cpusubtype:9
对于 armv7s:
cpu 类型:12 cpusubtype:11
现在我处于一种情况,我不可能以第三方的身份更新架构。所以我最终改变了我的 Xcode 构建项目:
Xcode 设置(蓝色标签) 项目和目标架构: 仅添加了 armv7 的有效架构 清理构建并再次运行还有一个替代解决方案是使用本教程Hacking an armv7s library。在我的情况下不起作用
【讨论】:
以上是关于为在 armv7s 上运行的 iOS 设备编译 Boost c++ 库的主要内容,如果未能解决你的问题,请参考以下文章
java.lang.UnsatisfiedLinkError CameraDetector 仅适用于 ARMv7 设备
适用于 iOS 的 leptonica 1.69 交叉编译(armv7、armv7s 和 arm64)
Xcode - 5.0.2, iOS 检查依赖项 没有要编译的架构 (ARCHS=i386, VALID_ARCHS=armv7 armv7s)[iOS 静态代码分析 - Jenkins]