【问题标题】:Cannot cross-compile static C library for iPhone (arm64) on macOS (x86_64)无法在 macOS (x86_64) 上为 iPhone (arm64) 交叉编译静态 C 库
【发布时间】:2021-08-18 06:41:21
【问题描述】:

我一直在尝试交叉编译静态 C 库以在 iOS 应用程序中使用。
我认为这可以通过将头文件和二进制文件包装在 XCFramework 中来实现,但是编译后的库是针对 x86_64 架构的,因此无法在 iOS 上运行。

我做了以下事情:

export IOS_SDK_LOC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
export AARCH64_FLAGS="-arch arm64 -isysroot $IOS_SDK_LOC "

./configure --host=arm_apple_darwin --build=x86_64_apple_darwin --target=x86_64_apple_darwin
          \ CFLAGS=$AARCH64_FLAGS CPPFLAGS=$AARCH64_FLAGS

我最初尝试只使用 CFLAGS,但最终传递了与 CPPFLAGS 相同的参数,并遵循Can't cross compile C library for arm (iOS) 的答案

在任何一种情况下,我都会收到相同的错误:
configure: error: cannot run test program while cross compiling

在这种情况下我应该如何编译我的库?

【问题讨论】:

    标签: ios macos cross-compiling


    【解决方案1】:

    我发现在同一台机器上编译 arm64 静态库的解决方法是安装 QEMU(机器模拟器),同时考虑目标操作系统。

    幸运的是,来自 Aleph Security 的 Jonathan Afek 最近为 iOS QEMU 编写了一个帧缓冲区,现在使用起来特别容易。

    更多信息在这里:https://www.reddit.com/r/jailbreak/comments/kxr0v8/news_ios_qemu_is_getting_a_graphical_display_ios/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      • 2011-11-05
      • 2022-08-24
      • 1970-01-01
      • 2021-04-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多