4

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?

Jiho Kang
  • 2,482
  • 1
  • 28
  • 38
  • Possibly, First things first, do you know if TBXML in both are IDENTICAL? That is they provide the same functionality... If so you can easily reconstruct the archive to remove one of them. – Ahmed Masud Dec 04 '11 at 18:08
  • Since I don't have the source code, I have no clue. :S Is there anyway I can find out? – Jiho Kang Dec 04 '11 at 18:09

1 Answers1

4

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.

Ahmed Masud
  • 21,655
  • 3
  • 33
  • 58
  • 1
    I've done what you suggested and as it turns out, they are quite different. The developers of the two libraries I'm trying to use should have been more considerate if they where going to modify and compile open source libraries(TBXML in this case) for re-distribution. I'm going to accept this answer and email the developers about this problem. Thanks. – Jiho Kang Dec 04 '11 at 19:06
  • @JihoKang I am sorry that i couldn't help you further.. and you are right. if they are going to use open source libraries then they should provide either the dynamically linked version of their libraries or provide the open source library separately so that you can cross link. – Ahmed Masud Dec 04 '11 at 19:08