views:

9

answers:

1
  • Development Tool : Sun Studio 11
  • Flags : CXXFLAGS=-O2 -g

I have two shared libraries, libA.so libB.so :

  • /A/root.cpp /A/a.cpp are used to generate libA.so
  • /B/root.cpp /B/b.cpp are used to generate libB.so
  • /A/root.cpp and /B/root.cpp is identifical

libA.so and libB.so will be dynamically loaded during main program running

when loading libA.so and then loading libB.so, libB.so will print the following debug info: /B/b.cpp : ..... /A/root.cpp : ...

when loading libB.so and then loading libA.so, libA.so will print the following debug info:

/A/a.cpp : .....
/B/root.cpp : ...

Why?

A: 

If you tried to compile this statically, the linker would complain about multiple definitions. Looks like the loader has gotten confused and is trying to fail gracefully.

http://uw714doc.sco.com/en/SDK_cprog/CCCS_LinkEdit.html#CCCS_HdlMultDefdSyms

spraff