I am trying to understand how g ++ chooses which version of libstdC ++ it links to, and what it means when the "system" version of the library is different.
I am using gcc / g ++ 4.1.2, which according to the ABI manual contains libstdC ++. so.6.0.8, and fairly confidently:
-rwxr-xr-x 1 root root 4397810 May 18 2007 /opt/gcc4.1.2/lib/libstdc++.so.6.0.8
Based on my understanding of advanced ABI compatibility, I can build with g ++ 4.1.2 and expect the code to run on a system with a later version of libstdC ++ than 6.0.8, but not one with an earlier version, because he will have an older version of ABI.
On the same computer, an older version of libstdc ++ is installed in / usr / lib:
-rwxr-xr-x 1 root root 804288 Jul 22 2005 /usr/lib/libstdc++.so.6.0.3
If I compile the code using g ++ 4.1.2 on this computer, then ldd, I see the version of libstdC ++ in / usr / lib that is referenced, which is 6.0.3:
It is expected that / usr / lib is checked first. And the application is working fine.
My question is: what happened here?
Is g ++ 4.1.2 related to libstdC ++ version, so is it part of this version (6.0.8)? If so, how is it that the executable can use the older version in / usr / lib at runtime when it has an older ABI? Luck?
Or did g ++ 4.1.2 choose the version of libstdC ++ (6.0.3) / usr / lib at link time and use it because it resolves library paths in the same way as executables at runtime? Can g ++ do this even if libstdc ++ is not its "own" version? What is the purpose of libstdc ++ version in g ++ 4.1.2 (6.0.8)? Is it used at all in this process?
Any ideas appreciated.
dtopham75
source share