Xcode: duplicate symbol

Source: Internet
Author: User

You must solve the problem of duplicate definitions in the referenced database.

The project needs to reference both zbar and QQ authorized logon sdks. Because both use base64 to process data, xcode compilation reports an error:

Duplicate symbol _ base64_encode in:

... \ Libzbar. A (symbol. O)

... \ Tencentopenapi (base64.o)


It means that _ base64_encode is defined in both databases, and the compiler thinks you have already defined it. As to why the compiler considers repeated definitions, I personally think that the compiler will compile global variables based on their names and will compile the global variables with the same name into the same variables, that is, multiple variables will be compiled into one, the compiler thinks this may cause errors and reminds the user of the errors.


Solution:

Reference: http://blog.sina.com.cn/s/blog_4beb28f301012bl6.html

Deleted set building-> Other linker flag->-all_load

The IOS framework is a shared dynamic library and will not be packaged into the app. Non-system framework static libraries will be packaged into the app. Therefore, a "Duplicate symbol" error will occur.
In build settings-> other link flags, delete all-all_load and-force_load. xcode removes "Duplicate symbol" smartly ".

The following is the ultimate solution strategy obtained from foreign friends. The solution is to modify the Class Library: I'm going to assume that these are two third party libraries that have only provided you with. A files and not the source code. you can use libtool, lipo and AR on the terminal to extract and
Recombine the files.

Assume that there are two third-party libraries that only provide you with the. A file without source code. You can decompress and merge them in terminal using libtool, lipo, and AR.
To see what ubuntures are in the file:

View the architecture supported by the file
$ Lipo-Info libtapjoy.
Ubuntures In the FAT file: libtapjoy. A are: armv6 i386

Then to extract just armv6, for example:

Decompress armv6, for example
$ Lipo-extract_family armv6-output libTapjoy-armv6.a libtapjoy.
$ Mkdir armv6
$ CD armv6
$ Ar-x ../libTapjoy-armv6.a

You can then extract the same architecture from the other library into the same directory and then recombine them like so:

You can extract the same architecture from another class library and then combine the two.
$ Libtool-static-o ../lib-armv6.a *. o

And then finally, after you 've done this with each architecture, you can combine them again with lipo:

As shown above, you can repeat all the architectures according to this process and then merge them.
$ CD ..
$ Lipo-create-output Lib. A lib-armv6.a lib-i386.a

This shoshould get rid of any duplicate symbols, but will also combine the two libraries into one. if you want to keep them separate, or just delete the duplicate from one library, you can modify the process
Accordingly. This process not only solves the duplicate symbols problem, but also combines the two class libraries into one. If you want to save two different class libraries, you can delete the duplicate part from any class library and modify the process accordingly.

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.