Skip to content

Instantly share code, notes, and snippets.

@cnsoft
Last active December 19, 2015 01:19
Show Gist options
  • Save cnsoft/5874985 to your computer and use it in GitHub Desktop.
Save cnsoft/5874985 to your computer and use it in GitHub Desktop.
解决 duplicate symboal appdelegate.o 的问题.
http://stackoverflow.com/questions/2910205/how-to-handle-duplicate-symbol-error-from-3rd-party-libraries
这个办法是解开.a文件删除 .o $OBJ—CLASS
down vote
I'm going to assume that these are two third party libraries that have only provided you with the .a files and not the source code. You can use libtool, lipo and ar on the terminal to extract and recombine the files.
To see what architectures are in the file:
$ lipo -info libTapjoy.a
Architectures in the fat file: libTapjoy.a are: armv6 i386
Then to extract just armv6, for example:
$ lipo -extract_family armv6 -output libTapjoy-armv6.a libTapjoy.a
$ 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:
$ 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:
$ cd ..
$ lipo -create -output lib.a lib-armv6.a lib-i386.a
This should 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.
@cnsoft
Copy link
Author

cnsoft commented Jun 27, 2013

mportant note: if you are using the pre-compiled static library and you are using the Reachability library in your project already, you will need to remove the implementation files for these libraries from your project as they are already compiled into the libPusher binaries. Leaving these files in your project will result in duplicate symbol errors from the linker. You should however leave the header files in your project in order to use them in your own source files.

https://github.com/lukeredpath/libPusher/wiki/Adding-libPusher-to-your-project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment