首页 > 解决方案 > 在 Azure Pipeline 中的 macOS 上构建 32 位 dylib

问题描述

我正在尝试从 Azure Pipeline 中 macOS 代理上的 C 文件构建 32 位 dylib。重要提示:我需要将 CoreServices 与我的共享库链接。我最初的构建脚本是:

gcc -c test.c
gcc -shared -framework CoreServices -o test.dylib test.o -m32

所以我用-m32switch 来输出 32 位文件。但在这里我得到错误:

ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks//CoreServices.framework/CoreServices.tbd, missing required architecture i386 in file /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks//CoreServices.framework/CoreServices.tbd
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd
Undefined symbols for architecture i386:
  "_CFAbsoluteTimeGetCurrent", referenced from:
      _StartHighPrecisionTickGenerator in NativeApi-macOS.o
  "_CFRunLoopAddTimer", referenced from:
      _RunLoopThreadRoutine in NativeApi-macOS.o
  ...
  "_memset", referenced from:
      _StartHighPrecisionTickGenerator in NativeApi-macOS.o
  "_pthread_create", referenced from:
      _StartHighPrecisionTickGenerator in NativeApi-macOS.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

据我所知,构建 32 位应用程序的能力已从最新的 macOS 版本中删除。

我发现我们可以使用 Xcode 9 来构建 32 位 dylib。Azure Pipelines 中还有一项特殊任务:Xcode@5。但我无法弄清楚如何使用此任务从原始 C 文件而不是 Xcode 项目/工作区构建 dylib。可能吗?我谈论的是 Azure Pipeline 任务,当然是命令行界面,而不是 GUI。

或者现在构建 32 位 dylib 可能是完全愚蠢的想法?这对 Windows 来说绝对重要(例如,对于标记为 .NET Framework 的应用程序prefer 32-bit),但也许 macOS 的 32 位应用程序是旧垃圾?

标签: cxcodemacosgccazure-pipelines

解决方案


推荐阅读