ldd output and executables
I have my executables built on both Forte Developer 7 and Sun Studio 11.
When I run "ldd" on my executables on both the systems, I found the following differences :
Where as Forte developer 7 lists the following libraries :
libCstd.so.1,
libCrun.so.1 and
libw.so.1
But the above libraries were not listed for the executables on Sun Studio 11.
Where as Sun Studio 11 lists the following library :
libC.so.5
But the above library was not listed for the executables on Forte Developer 7.
And surprisingly, the code which was built on Studio 11 is running FINE on Forte Developer 7 !
Does it mean libC.so.5 compensates for libCstd.so.1, libCrun.so.1 and libw.so.1 ?
Should I worry that "My executables are running FINE on Forte Developer 7 which was compiled on Sun Studio 11" ?
# 1
By default, both compiler versions generate code for standard C++ and link to libCrun and libCstd.
If you use the option -compat or -compat=4, both compilers generate old-style C++ code, and link to libC instead of to libCrun and libCstd.
Apparently the code compiled by Studio 11 used the -compat[=4] option and the code compiled by FD7 did not.
In general, you cannot mix standard-mode code with -compat[=4] code. In addition, code compiled by a later compiler cannot in general be linked into a program built with an earlier compiler.
Refer to the C++ Migration Guide that comes with the compiler for full details.
You can mix binaries from different compiler versions as long as you follow these rules:
1. Compilation options must be compatible. In particular, don't mix standard-mode code with -compat=4 code.
2. Use the later compiler to link the final program or shared libraries. You can include binaries created by the earlier compiler .
In rare circumstances you can get away with violating these rules, but you cannot depend on the program working correctly.
# 2
Thank you very much .
Actually , the whole application including our libraries, shared objects and executables ...all were built on Studio 11. I am not mixing my executables with any of "our" libraries or shared objects which were built on Forte Developer 7. Do you think it is still not good ?
When you said I should not link, did you mean I should not link my executables (built on studio 11) with standard libraries like libCStd and libCrun (from Foret Developer 7)?
Thanks again.
Message was edited by:
RameshACSTS
# 3
The compatibility rule is that you can link your old binaries or 3rd-party binaries created by older compilers into a program built with a new compiler.
You cannot link system libraries from one compiler installation into a program built with a different compiler.
By default, the compiler links the shared (dynamic) version of libCstd and libCrun from /usr/lib. You can force the compiler to use the static versions of those libraries that come with the compiler, but we strongly recommend that you never link those libraries statically.
The shared libraries in /usr/lib are part of the Solaris installation, and are updated by Solaris patches for package SUNWlibC. The program picks up those libraries at run time from the system on which it is running.
Each compiler has a minimum required patch level for SUNWlibC (C++ Runtime Libraries). The required patch level is listed in the compiler documentation, and the patches are included in the compiler distribution. You can always use a later patch level than the minimum level.
You can get all current patches here:
http://developers.sun.com/prodtech/cc/downloads/patches/index.jsp
# 4
Thanks again.
Based on your earlier explanation, I thought of compiling my code again with -compat set to 5 ( I hope this is right for Standard mode ).
The code got compiled. And I ran ldd on one of the executables. I was expecting libCrun and libCstd instead of libC.so.5 . But ldd listed libC.so.5 again. Am I missing something here ? Thanks in advance for your inputs.
# 5
Are you linking a shared library that you did not build? If so, run ldd on it and see whether it has a dependency on libC.so.5.
If that is not the problem, please show a typical CC command line used for compiling, and the command line you use for linking. Please show the complete command lines. You don't need to show the names of .cc or .o files -- you can just show *.cc or *.o.