two static libraries with duplicate symbols in Xcode

笑着哭i 提交于 2019-12-07 15:17:22

问题


I have two static libraries which seem to have duplicate symbols(TBXML.o) and won't compile.

ld: duplicate symbol _OBJC_METACLASS_$_TBXML in /Users/Hoya/Desktop/SocialSync/include/SMUFLib/deviceLib/libSFCommonLibs.a(TBXML.o) and /Users/Hoya/Desktop/SocialSync/Cauly/libCaulyDevice.a(TBXML.o) for architecture armv6
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1

The developer of both libraries don't provide the source code so there is nothing I can do to edit the code directly to fix it.

Is there anything I can do to work around this without nagging the library developers?


回答1:


Part 1 -- Figuring out whether or not the symbols represent same object.

Note: This is OS X specific.

Okay let's look at how to can look at their disassembly.

You may be able to use the otool to do this:

otool -v -t '/Users/Hoya/Desktop/SocialSync/Cauly/libCaulyDevice.a(TBXML.o)' 

and

otool -v -t '/Users/Hoya/Desktop/SocialSync/include/SMUFLib/deviceLib/libSFCommonLibs.a(TBXML.o)'

Examine the disassembly to see if they are the same, if so then you are in luck :-)

If the foo.a(bar.o) format of the above commands doesn't work (for whatever reason although it should) you can try it by removing the (TBXML.o) from both but then you'd have to do a bit more work.

If they ARE the same then you can easily use the otool + lipo to rebuild ONE of the two .a files so that TBXML.o is not in it

In case they aren't the same then a lot more trickery has to be done :) may not even be possible easily.



来源:https://stackoverflow.com/questions/8377420/two-static-libraries-with-duplicate-symbols-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!