IOS Static library conflicts with a different. o file conflict, static library separation

Source: Internet
Author: User


When integrating zbar and payments during development, many hints are found to be. o file conflicts, the most common when base64 conflicts, because many third-party static libraries have base64 this file
On the internet for a long time, found are reproduced in the same article, because of the console command is not familiar with, also spent a lot of Kung Fu, asked the master, and finally took care of
The following method is attached,

Open the console terminal and find the. a file to dissect. (You can copy one copy, I copy one to the desktop), execute the following command to see the CPU schema code that the library contains: xcrun-sdk Iphoneos lipo-info libx.a
Architectures in the Fat file:libx.a are:i386 armv7 armv7s//Here if you are using the Lipo command directly you will see: I386 armv7 (Cputype) Subcputyp (11))
/USERS/HELLO/DESKTOP/LIBCRYPTO.Ais the file path
bogon:~ hello$ lipo-info/users/hello/desktop/libcrypto.aarchitectures in the FAT file:/users/hello/desktop/libcrypto.a are:armv7 armv7s i386 x86_64 arm64
and then use
XCRUN-SDK Iphoneos lipo-extract_family i386-output libx-i386.a libx.a
XCRUN-SDK Iphoneos lipo-extract_family armv7-output libx-inter.a libx.a
bogon:~ hello$ lipo-extract_family i386-output/users/hello/desktop/libcrypto-i386.a/users/hello/desktop/ LIBCRYPTO.Abogon:~ hello$ lipo-extract_family armv7-output/users/hello/desktop/libcrypto-inter.a/users/hello/desktop/ LIBCRYPTO.A

Isolate the arm version of. A, here's a little problem, as I understand it. This command should operate on the armv6 part of the. A that contains 3 CPU codes, while the actual isolated. A is the part that contains both ARMV7 and armv7s, which is still the "fat" lib, It is not possible to extract the. O, so you need to do the following:
Lipo Libx-inter.a-thin armv7-output Libx-armv7.alipo libx-inter.a-thin armv7s-output LIBX-ARMV7S.A
bogon:~ hello$ Lipo/users/hello/desktop/libcrypto-inter.a-thin armv7-output/users/hello/desktop/ LIBCRYPTO-ARMV7.Abogon:~ hello$ Lipo/users/hello/desktop/libcrypto-inter.a-thin armv7s-output/users/hello/desktop/ LIBCRYPTO-ARMV7S.A
This allows the separation of 2 different versions of ARM's. A, and then the solution. O Operation:
Ar-x libx-armv7.a This is best done in a separate folder.(/users/hello/desktop/armv7/) file armv7 folder path on the desktopOperate this procedure in a folderbogon:home hello$ cd/users/hello/desktop/armv7/bogon:armv7 hello$ ar-x/users/hello/desktop/armv7/libcrypto-armv7.a, will link out. A of all. O is restored, and then there are two options: one is to restore all the libraries corresponding to the CPU architecture to this location, and then merge the duplicate parts into one copy, then use the following command to merge all the. O into a public lib. Another option is to keep a copy of the duplicate symbol Lib intact, the remaining Lib alone, remove the duplicate symbol exists. o, and then link the Lib back to. A to remove the repetition symbol. Whichever method is used, the last link back command is as follows: Libtool-static-o. /LIBX-ARMV7.A *.Obogon:armv7 hello$ Libtool-static-o. /libcrypto-armv7.a *.o ". A and * number has a space"still operating in the ARMv7 folder, it will be regenerated in the previous level file of ARMv7. A file (because my previous level of directory is the desktop so directly overwrite the original desktop file)"I checked this out. Has no symbols"Seems to be just a hint of nature, not an error hint"Of course, let's not forget that our library has multiple CPU architecture instructions, so we'll do the same for each of the CPU arch libraries, and then merge thin lib back into the fat lib:lipo-create-output libx.a libx-armv7.a LIBX-I386.A LIBX-ARMV7S.A
Finally merge into a. A file to replace the. A file in the project.
This way, link back to your app will no longer appear duplicate symbol.

IOS Static library conflicts with a different. o file conflict, static library separation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.