Jiho Kang
Jiho Kang

Reputation: 2492

two static libraries with duplicate symbols in Xcode

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?

Upvotes: 4

Views: 2282

Answers (1)

Ahmed Masud
Ahmed Masud

Reputation: 22402

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.

Upvotes: 4

Related Questions