28

How to merge the static libraries into single one?

I do have three static libraries libSignatureLibary_armv6.a , libSignatureLibary_armv7.a and libSignatureLibary_i368.a

Now i want to merge this three file into one single library which may be named has libSignatureLibary.a

While Googling I found lipo which is open source tool!

Do i need to run any extra scripting language to merge

or in terminal lipo and pass the parameter for the lipo.

Can any on advice me to build the common library for these three.

@thanks in advance Kiran

2
  • do you prefer command-line or xcode? Commented Jun 20, 2012 at 21:29
  • Any Thing ! that need to merge the files~ if possible let me know the path! Commented Jun 21, 2012 at 7:30

3 Answers 3

50

Open terminal and go to folder with your libs. Then use command:

lipo libSignatureLibary_armv6.a libSignatureLibary_armv7.a libSignatureLibary_i368.a -create -output libSignatureLibary.a 
Sign up to request clarification or add additional context in comments.

Comments

4

lipo command

Create or operate on a universal file: convert a universal binary to a single architecture file, or vice versa.

lipo from the liposuction. As you know when you build a project Xcode generate binary for different CPU architectures.

  • Unite. When a developer wants to share a producer binary as a closed-sorce he should take into account that a client should have a possibility to run/debug a project with this binary on a real device and a simulator. This simple example shows that the developer has to have a tool to merge binary for different arch into a single file - fat binary.

  • Separate. Another example is when you publish an app to AppStore you can remove unnecessary arch using -remove option.

  • If you try to build a project with a binary without necessary arch you get an error[Could not find module for architecture]

Architectures:

  • Simulator - x86_64, i386
  • Device - armv7, armv7s, arm64

If you try run this command for binaries with the same arch you will get

fatal error: <binary_list> have the same architectures (<arch>) and can't be in the same fat output file 

Please note that -create option do not have parameters

lipo libMy_armv6.a libMy_armv7.a libMy_i368.a -create -output libMy.a 

To check existing architectures

lipo -info <binary_path> //or file <binary_path> 

Next step is [XCFramework]

[Vocabulary]

Comments

-1
lipo -create libSignatureLibary_armv6.a libSignatureLibary_armv7.a libSignatureLibary_i368.a -output libSignatureLibary.a 

3 Comments

lipo -create libSignatureLibary_armv6.a libSignatureLibary_armv7.a libSignatureLibary_i368.a -output libSignatureLibary.a
Please edit with more information. Code-only and "try this" answers are discouraged, because they contain no searchable content, and don't explain why someone should "try this".
This is the exact same as the accepted answer with less information.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.