【问题标题】:linker error while linking to arm64 library on Xcode链接到 Xcode 上的 arm64 库时出现链接器错误
【发布时间】:2019-02-19 15:03:07
【问题描述】:

我正在尝试为 arm64 构建我的项目。这个项目需要一个 arm64 libcrypto.a。我想知道我是否缺少任何设置。提前谢谢...

我看到的错误是:

ld: warning: ignoring file /Users/Amy/Desktop/swift_proj/swift_proj/include/libcrypto.a, file was built for archive which is not the architecture being linked (x86_64): /Users/Amy/Desktop/swift_proj/swift_proj/include/libcrypto.a

我的项目设置如下图:

Architectures: arm64
Base SDK: Latest iOS(iOS 11.4)
Build Active Architecture Only: No
Supported Platforms: iOS
Valid Architectures: arm64

我已将 info.plist 中的“RequiredDeviceCapabilities”更新为 arm64。
我已经检查了我要链接的库的类型:

[Amys-MacBook-Air:include$ lipo -info libcrypto.a 
input file libcrypto.a is not a fat file
Non-fat file: libcrypto.a is architecture: arm64

我不明白为什么错误显示该项目是为 x86_64 构建的。

【问题讨论】:

  • 你用的是什么版本的xcode?​​span>
  • @Hary:我在 Mac High Sierra(10.13.6) 上使用 Xcode 9.4.1。
  • 您是否要为模拟器目标构建?
  • @pckill :不,我正在尝试为实际的 iphone 构建。我是否需要连接手机才能成功构建项目?
  • 否,但您应该为 Xcode 选择正确的设备来构建正确的架构。如果您的手机未连接,请使用Generic iOS Device

标签: ios xcode linker arm64


【解决方案1】:

看起来 OpenSSL 在多架构构建方面存在一些问题,您需要解决这些问题才能使其正常工作,这里的答案 Build Multiarch OpenSSL on OS X 应该会有所帮助。

基本上,您必须使用#ifdef 替换几个包含特定于架构的头文件的 OpenSSL 头文件,以便在编译时检查系统架构。在从源代码为您想要的每个目标构建 OpenSSL 之后执行此操作。然后,您将能够使用lipo 工具将每个目标的 OpenSSL 静态库构建组合到一个静态库中,然后使用它。

【讨论】:

    猜你喜欢
    • 2018-12-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 2012-01-15
    • 2019-11-07
    • 1970-01-01
    • 2013-04-26
    相关资源
    最近更新 更多