Pre-link static libraries for the ios project

I have a large iOS project, consisting of several (about 20-30) static libraries that are linked together into the final executable. Some of the components are platform independent (pure C ++), and some are iOS-specific (Obj-C / Obj-C ++). C ++ templates are heavily used, so each object file contains many characters with fuzzy binding. The problem is that these characters merge only when linking the final executable file, but not when creating static libraries. Each library contains tons of duplicated characters (6-60 clones). Thus, the final build of the application takes several minutes. This becomes extremely annoying when debugging and making small changes.

Is there a way to merge undefined-linked characters for each library?

I knew this was done automatically when using dynamic libraries. With some hacks (http://sumgroup.wikispaces.com/iPhone_Dynamic_Library) you can create dynamic libraries for iOS. Is there a way to link dylib statically (link them to a single executable)?

Of course, debugging the resulting application is a must.

+4
source share
1 answer

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

  • In your only (main) library, go to "Build Settings" and find Perform Single-Object Prelink in the "Binding" section. Switch to Yes
  • In Prelink libraries, you can specify other libraries that you want to include. There you need to specify not only the names, but also the full file name. If other libraries are also from your project, you can use the $(CONFIGURATION_BUILD_DIR) variable. Therefore, if you have a foo library, it will be $(CONFIGURATION_BUILD_DIR)/libfoo.a
  • You can add additional flags in the flags of the preliminary binding of one object.
  • If you want to strip out local characters, make sure that you have the deployment deployment post set to "Yes" because static libraries are not deleted by default.
+10
source

All Articles