链接到Xcode上的arm64库时出现链接器错误

时间:2019-02-19 15:03:08

标签: ios xcode linker arm64

我正在尝试为arm64构建我的项目。该项目需要arm64 libcrypto.a。我想知道是否缺少任何设置。预先感谢...

我看到的错误是:

Flutter doctor:

/work/sdk/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.3 18D109, locale en-BE)
    • Flutter version 1.0.0 at /work/sdk/flutter
    • Framework revision 5391447fae (3 months ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /work/sdk/Android
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /work/sdk/Android
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.6.0

[✓] Android Studio (version 3.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 33.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] IntelliJ IDEA Ultimate Edition (version 2018.3.4)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.io/intellij-setup/#installing-the-plugins

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

! Doctor found issues in 1 category.

我的项目设置如下所示:

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

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

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

我不明白为什么该错误说明该项目是针对x86_64构建的。

1 个答案:

答案 0 :(得分:1)

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

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