xcode 为 armv6 和 armv7 构建 iPhone 静态库,其中包含另一个静态库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2456795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:12:04  来源:igfitidea点击:

Building iPhone static library for armv6 and armv7 that includes another static library

iphonexcodestatic-librariesuniversal-binaryfat-binaries

提问by Martijn Thé

I have an Xcode project that has a "master" static library target, that includes/links to a bunch of other static libraries from other Xcode projects.

我有一个 Xcode 项目,它有一个“主”静态库目标,它包含/链接到来自其他 Xcode 项目的一堆其他静态库。

When building the master library target for "Optimized (armv6 armv7)", an error occurs in the last phase, during the CreateUniversalBinary step. For each .o file of the libraries that is included by the master library, the following error is reported (for example, the FBConnectGlobal.o file):

为“Optimized (armv6 armv7)”构建主库目标时,在最后一个阶段,即 CreateUniversalBinary 步骤期间发生错误。对于主库包含的库的每个.o文件,都会报如下错误(例如FBConnectGlobal.o文件):

warning for architecture: armv6 same member name (FBConnectGlobal.o) 
in output file used for input files: /Developer_Beta/Builds/MTToolbox/MTToolbox.build/Debug-iphoneos/MTToolbox.build/Objects-normal/armv6/libMTToolbox.a(FBConnectGlobal.o) 
and: /Developer_Beta/Builds/MTToolbox/MTToolbox.build/Debug-iphoneos/MTToolbox.build/Objects-normal/armv7/libMTToolbox.a(FBConnectGlobal.o) 
due to use of basename, truncation and blank padding

In the end, Xcode tells that the build has succeeded. However, when using the final static library in an application project, it won't build because it finds duplicate symbols in one part of build (armv6) and misses symbols in the other part of the build (armv7).

最后,Xcode 告诉我们构建成功。但是,在应用程序项目中使用最终静态库时,它不会构建,因为它在构建的一个部分 (armv6) 中找到了重复的符号,而在构建的另一部分 (armv7) 中找不到符号。

Any ideas how to fix this?

任何想法如何解决这一问题?

M

回答by jamie

I dont think that's the answer at all. It will totally work if you don't have two architectures in there. In the example given in the link, it is possible to link libraries a, b, and c into one library, and link with that.

我认为这根本不是答案。如果那里没有两个架构,它完全可以工作。在链接中给出的示例中,可以将库 a、b 和 c 链接到一个库中,然后与之链接。

The problem that Carl is having is that there are two different architectures in the library (arm6 and arm7) and the linker is failing to resolve them correctly.

Carl 遇到的问题是库中有两种不同的架构(arm6 和 arm7),并且链接器无法正确解析它们。

I found the problem. Its a bug in libtool as far as I can tell. See my post for a solution:

我发现了问题。据我所知,它是 libtool 中的一个错误。请参阅我的帖子以获取解决方案:

https://binaryfinery.wordpress.com/2010/06/11/universal-static-library-problem-in-iphone-sdk/

https://binaryfinery.wordpress.com/2010/06/11/universal-static-library-problem-in-iphone-sdk/

回答by broderix

Another fix I found is to set Architectures to "armv6". ARCHS_STANDARD_32_BIT changed from armv6 to "armv6 armv7" which aggravates the libtool bug you describe above. Obviously it won't be producing armv7 optimized binaries, but it should still work fine on iPhone 4.

我发现的另一个解决方法是将 Architectures 设置为“armv6”。ARCHS_STANDARD_32_BIT 从 armv6 更改为“armv6 armv7”,这加剧了您在上面描述的 libtool 错误。显然它不会生成 armv7 优化的二进制文件,但它仍然可以在 iPhone 4 上正常工作。