用于ios项目的预链接静态库 [英] pre-link static libraries for ios project

查看:180
本文介绍了用于ios项目的预链接静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大的iOS项目,由几个(约20-30)静态库组成链接到最终的可执行文件。一些组件是平台无关的(纯C ++),一些是特定于iOS的(Obj-C / Obj-C ++)。 C ++模板被集中使用,因此每个目标文件包含许多具有模糊链接的符号。问题是这些符号仅在最终可执行文件的链接期间合并,但是在创建静态库时不会合并。每个库包含吨重复的符号(6-60克隆)。所以最终链接的应用程序需要几分钟。

I have a big iOS project that consists from several (about 20-30) static libraries that link together into final executable. Some of the components are platform-independent (pure C++) and some are iOS-specific (Obj-C/Obj-C++). C++ templates are used intensively, so each object file contains lots of symbols with vague linkage. The problem is that these symbols are merged only during linking of the final executable, but not when making static libraries. Each library contains tons of duplicated symbols (6-60 clones). So final linking of the app takes several minutes. This becomes extremely annoying when debugging and doing some small changes.

有没有办法对每个库执行带有模糊链接的符号合并?

Is there a way to perform merging of the symbols with vague linkage for each library?

我知道,这是使用动态库时自动完成。使用一些黑客(http://sumgroup.wikispaces.com/iPhone_Dynamic_Library),可以为iOS构建动态库。有没有办法链接dylib的静态(链接到一个单一的可执行文件)?

I known, that this is done automatically when using dynamic libraries. With some hacking (http://sumgroup.wikispaces.com/iPhone_Dynamic_Library) it is possible to build dynamic libraries for iOS. Is there a way to link dylib's statically (link them into a single executable file)?

当然,能够调试结果应用程序是必须的。

Of course, being able to debug resulting app is a must.

推荐答案

您可以将静态库对象预链接到一个单独的对象,也可以将其他静态库预链接到一个。

You can pre-link your static library objects into a single one, also you can prelink other static libraries into one. It will actually link objects with the linker (almost like in dynamic library).


  1. 在您的单个库(主要的)中,转到Build设置并在链接部分中找到执行单对象预链接。将其切换为是

  2. 在预链接库中,您可以指定要包括的其他库。在那里你需要不仅仅是名称,而是完整的文件名。如果其他库也来自你的项目,那么你可以使用 $(CONFIGURATION_BUILD_DIR)变量。所以如果你有库foo,那么它将 $(CONFIGURATION_BUILD_DIR)/libfoo.a

  3. -Object Prelink Flags

  4. 如果要除去局部符号,请确保将部署后处理设置为是,因为默认情况下不会除去静态库。

  1. In your single library (the main one) go to Build Settings and find Perform Single-Object Prelink in Linking sections. Switch that to Yes
  2. In Prelink libraries you can specify other libraries you want to include. There you need to put not just names, but full file name. If other libraries are also from your project, then you can use $(CONFIGURATION_BUILD_DIR) variable. So if you have library foo, then it will be $(CONFIGURATION_BUILD_DIR)/libfoo.a
  3. You can add additional flags in Single-Object Prelink Flags
  4. If you want to strip out local symbols, then make sure that you have Deployment Postprocessing set to Yes, as by default static libraries are not stripped out.

这篇关于用于ios项目的预链接静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆