1

My project is using ACE library, and need link another library libsdk.so, it's using another version ACE library.

The link order like : ...-lMyAce -lsdk -lAnotherAce

When application running, libsdk.so called method in MyAce(I checked the core dump), and the application crash.

If I change link order to: ...-lsdk -lAnotherAce -lMyAce

My code called method in AnotherAce, it's also crash.

If I only link my ACE, it's crash. There are some link error if only link AnotherAce.

Let the libsdk.so call its ACE library, and my code call my ACE library. How can I resolve the problem?

  • The link order won't help here. If two libraries define the same symbol the earlier definition will always win. You can decide *which* one wins, but you can't have both. – ams Jan 15 '13 at 09:34
  • Do you have control of the libraries? I.e. could you modify them, at all? – ams Jan 15 '13 at 09:35
  • @ams It seems like the link order decide the loading order. First loading win. – Wenbo Huang Jan 15 '13 at 09:58

1 Answers1

1

The Solaris linker has an option that may help, though really redesigning your application to not need two sets of libraries with the same names in the same program is going to be the best solution.

Direct Bindings record in each library or program which library it found a symbol in, so if libsdk.so is built with -B direct -lAnotherAce, it will record each of its references go to AnotherAce, not MyAce. You'd then link your code with -B direct -lsdk -lMyAce (do not include -lAnotherAce, as the libsdk dependencies take care of that), and your code would record that it's calls to to MyAce.

alanc
  • 4,102
  • 21
  • 24