问题描述
我有两个第三方库,似乎使用相同的类。这应该很好,但是我建立时遇到这种类型的错误:
ld:重复符号.objc_class_name_CJSONScanner in / Users / myappOne / TapjoyConnect / Frameworks / libTapjoyConnectSimulatorRewardInstall_Ads_Pinch.a(CJSONScanner.o)和/Developer/Projects/BuildOutput/Debug-iphonesimulator/OtherLibrary_d.a(CJSONScanner.o)
如何处理此问题...
- EDIT -
...如果源文件不可用?
这些是两个只提供了.a文件而不是源代码的第三方库。您可以使用libtool,lipo和ar在终端上提取和重新组合文件。
要查看文件中的结构:
$ lipo -info libTapjoy.a
fat文件中的架构:libTapjoy.a是:armv6 i386
然后只提取armv6,例如:
$ lipo -extract_family armv6 -output libTapjoy-armv6.a libTapjoy.a
$ mkdir armv6
$ cd armv6
$ ar -x ../libTapjoy-armv6.a
然后,您可以将同一架构从其他库提取到同一目录中,然后重新组合它们,如下所示:
$ libtool -static -o ../lib-armv6.a * .o
然后,最后,在每个架构完成此操作后,您可以再次使用lipo:
$ cd ..
$ lipo -create -output lib.a lib-armv6.a lib-i386.a
这应该去掉任何重复的符号,但也会将两个库合并成一个。如果您要将它们保持分开,或者只是从一个库中删除重复,您可以相应地修改该过程。
I have two 3rd party libraries that seem to use the same class. That should be fine but I'm getting this type of error when building:
ld: duplicate symbol .objc_class_name_CJSONScanner in /Users/myappOne/TapjoyConnect/Frameworks/libTapjoyConnectSimulatorRewardInstall_Ads_Pinch.a(CJSONScanner.o) and /Developer/Projects/BuildOutput/Debug-iphonesimulator/OtherLibrary_d.a(CJSONScanner.o)
How can I handle this issue...
-- EDIT --
...if the source files are not available?
解决方案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.
这篇关于如何处理来自第三方库的重复符号错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!