简体   繁体   English

链接英特尔库以在 M1 Mac 上使用 Xcode 生成英特尔二进制文件

[英]Link Intel Library to Generate Intel Binary on M1 Mac with Xcode

I have 16" M1 Pro MacBook Pro. The third party C library (.a) was built with Intel Mac and there's absolutely no way to modify the code or rebuild with M1 Mac. The binary is x64 binary.我有 16" M1 Pro MacBook Pro。第三方 C 库 (.a) 是使用 Intel Mac 构建的,绝对无法修改代码或使用 M1 Mac 重建。二进制文件是 x64 二进制文件。

My project is using C++ and Objective-C++ (.mm) with Xcode.我的项目是在 Xcode 中使用 C++ 和 Objective-C++ (.mm)。 It is targeted for Mac app and not iOS.它针对的是 Mac 应用程序而不是 iOS。 I want to link the C library to my project.我想将 C 库链接到我的项目。

The linked library 'libkfunc64.a' is missing one or more architectures required by this target: arm64.链接库“libkfunc64.a”缺少此目标所需的一个或多个架构:arm64。

I checked similar question but it didn't work:我检查了类似的问题,但没有奏效:

Can Xcode on m1 Mac build targeting Intel 可以在 m1 Mac 上构建针对英特尔的 Xcode

What I want to do is to generate an Intel binary.我想要做的是生成一个英特尔二进制文件。 I don't need a M1 binary or hybrid binary - I can run Intel binary on Rosetta 2 on M1 Mac.我不需要 M1 二进制文件或混合二进制文件 - 我可以在 M1 Mac 上的 Rosetta 2 上运行英特尔二进制文件。

I created a console-app with "-arch x86_64" option for LLVM C++ compiler and it worked.我为 LLVM C++ 编译器创建了一个带有“-arch x86_64”选项的控制台应用程序,它可以工作。 But I don't know how to pass that option on Xcode.但我不知道如何在 Xcode 上传递该选项。

Please tell me how to do it.请告诉我该怎么做。 I am using Xcode 13.3.我正在使用 Xcode 13.3。

Xcode - Targets - Build Settings Architectures (x86_64) or Excluded Architectures(arm64). Xcode - 目标 - 构建设置架构(x86_64)或排除架构(arm64)。 I've only tested the opposite.我只测试了相反的情况。
Arm64 required, no x86_64.需要 Arm64,不需要 x86_64。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM