刚好有这个需求,记录下怎么加参数完成交叉编译。

在使用automake进行configure时带上交叉编译参数:

./configure CFLAGS="-arch x86_64 -pipe -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.2.sdk" --host="i686-apple-darwin"
  • 其中arch参数为target的架构,如x86_64arm64等。
  • 其中host参数模拟器为i686,真机为arm
  • 其中isysroot需要指定Xcode的SDK路径,可以用xcrun --sdk "iphonesimulator" --show-sdk-path得到,其中sdk参数模拟器为iphonesimulator,真机为iphoneos

将模拟器与真机分别指定target编译后得到的库使用lipo整合:

ls
# result: libfoo-arm64.a libfoo-x86_64.a
lipo -create ./* -output libfoo.a

然后在Project桥接头内include头文件,link整合后的库即可使用。

文章作者: Blink Chen
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 kingcyk's Blog
技术活儿 iOS
喜欢就支持一下吧