1

I want to create a iOS project using c static libraries. I have downaloaded these files

ohNetGenerated-iOs-arm64-Debug.tar.gz

ohNetGenerated-iOs-arm64-Release.tar.gz

ohNetGenerated-iOs-armv7-Debug.tar.gz

ohNetGenerated-iOs-armv7-Release.tar.gz

ohNetGenerated-iOs-x86-Debug.tar.gz

ohNetGenerated-iOs-x86-Release.tar.gz

When I extract them they all have: libohNetGeneratedDevices.a

How can I generate a fat library? Is it possible

Thank you

Reimond Hill
  • 4,278
  • 40
  • 52
  • You want to generate one lin which contains all of the contents of those? I have the impression that only one of them is supposed to be used at a time. I.e. I expect that they will have heavily overlapping APIs. – Yunnosch Jun 16 '18 at 12:00
  • Please explain about the "Why?". I feel that we might be dealing with an XY problem. https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – Yunnosch Jun 16 '18 at 12:00
  • Check this: https://stackoverflow.com/questions/8170450/combine-static-libraries – arturdev Jun 16 '18 at 12:30

1 Answers1

1

Use lipo to create a fat library:

lipo -create armv7/libmylib.a arm64/libmylib.a x86/libmylib.a -output libfat.a

You can combine the versions of the library that are for different architectures in a fat library, but you can't combine versions of the library that are for the same architecture, so you can't combine the Release and Debug versions of the same architecture.

Samuel Peter
  • 4,136
  • 2
  • 34
  • 42
  • Glad it works! Yes, you can use `lipo -info libfat.a` to see the architectures inside – Samuel Peter Jun 16 '18 at 13:48
  • Yes It also works!, I run the info and it says: Architectures in the fat file: ohNetDevicesFatDebug.a are: armv7 i386 arm64. The library has includes, any of them (if I just include arm64 for example) would work using the the libfat.a, isn't it? – Reimond Hill Jun 16 '18 at 13:53
  • Yes normally the header files are platform independent. Strictly speaking it's not necessarily the case as they can contain macros or inline functions that can contain inline assembly or compiler intrinsics specific for a platform. But it's a safe bet and if not you will find out during compilation – Samuel Peter Jun 16 '18 at 14:50
  • Thank you very much again! I would upvote you more times but i can't :) – Reimond Hill Jun 16 '18 at 15:13