That’s because your CustomiPhoneLib.a is a fat library, i.e., a library that contains more than one target architecture, namely armv6 and armv7 on iOS. You can use lipo
to extract a specific architecture into another .a file, use ar
and ranlib
to manipulate it at will, and then use lipo
again to recombine the manipulated .a files into a single .a fat file. For instance,
lipo CustomiPhoneLib.a -thin armv6 -output CustomiPhoneLibarmv6.a
lipo CustomiPhoneLib.a -thin armv7 -output CustomiPhoneLibarmv7.a
### use ar and ranlib at will on both files
mv CustomiPhoneLib.a CustomiPhoneLib.a.original
lipo CustomiPhoneLibarmv6.a CustomiPhoneLibarmv7.a -create -output CustomiPhoneLib.a
However, you don’t have to do this for the reason you’ve mentioned. The linker will only pull object (.o) files from a library (.a) if it needs to resolve some symbol reference. Therefore, if a library contains an object file whose symbols are never referenced during the linking process (i.e., symbols that are not effectively used), that object file won’t make it into the executable.
Code:
ar -t mylib.a
This will list all of the files in the archive.
Code:
ar -xv mylib.a myobj.o
This will extract the object give myobj.o from the library mylib.a.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With