0

App A requires third-party libraries B and C. Both B and C include different versions of library D (from a further third-party). No third-party source code is available. This will give duplicate symbol errors when linking the app.

What solutions are available?


Related question involving identical libraries, allowing one copy to simply be deleted: How to handle duplicate symbol error from 3rd party libraries?

Community
  • 1
  • 1
OrangeDog
  • 36,653
  • 12
  • 122
  • 207
  • The answer given is a perfectly valid approach. What's the problem in using it? – Anya Shenanigans Jan 09 '15 at 20:12
  • If the two versions of the library are not binary compatible, then removing one copy will break the code relying on it. – OrangeDog Jan 09 '15 at 20:14
  • There aren't a lot of approaches you can take in that case - you would have to merge B & D into a shared framework exposing only the classes that B provides; then do the same for C & D then you should be able to link B & C to A; I don't know how the objective-c run-time would behave in that case, though. It's an approach I use for C/C++ libraries but I've never tried it with objective-c. Plus, I don't know if the objective-c run-time would do the right thing in that case – Anya Shenanigans Jan 09 '15 at 21:18

1 Answers1

0

This was solved by renaming the conflicting symbols in B (and its version of D if separate). This can be done directly on the binary as long as the renames are the same length as the originals (e.g. by reversing the library prefix).

local $/ = "\0";
open my $fh, '<+', $library;
binmode $fh;

while (my $field = <$fh>) {
    my $length = length $field;
    chomp $field;

    if (defined $translation{$field}) {
        seek $fh, -$length, SEEK_CUR;
        print $fh $translation{$field};
    }
}
OrangeDog
  • 36,653
  • 12
  • 122
  • 207