How to find out which C library I am using?
807578Jun 28 2008 — edited Jun 29 2008On my Solaris 9 UltraSparc system,
% echo $LD_LIBRARY_PATH
/opt/gcc/3.4.4/lib:/opt/glib/2.12.1/lib:/opt/gnome/lib:/opt/openssl/0.9.7g/lib
% /usr/lib/libc.so
usage: ld.so.1 [-e option,...] dynamic-object [object args,...]
On my Solaris 10 x86 system,
% echo $LD_LIBRARY_PATH
/pkg/gcc/4.2.1/lib:/opt/gcc/current/lib:/opt/glib/2.10.1/lib:/usr/sfw/lib:/usr/lib/mps:/opt/openldap/lib:/opt/openssl/current/lib
% /usr/lib/libc.so
usage: ld.so.1 [-e option,...] dynamic-object [object args,...]
On my Linux/x86 system,
% echo $LD_LIBRARY_PATH
/opt/openssl/0.9.7g/lib:/opt/gcc/3.4.4/lib:/opt/binutils2.13/lib:/opt/glib/2.12.1/lib:/opt/java/j2sdk1.4.1_01/lib
% /lib/libc.so.6
GNU C Library stable release version 2.6.1, by Roland McGrath et al.
....
From the above, can one tell what C library I am linking to on the Solaris systems? If not, how can one tell? How do I know the exact location of the C library I am using?
On the Linux/x86 system, I can use gnu_get_libc_version() to find out the version of glibc I am supposedly using. But it does not work when I compiled the identical C program using gcc on the Solaris 9/UltraSparc and Solaris 10/x86 systems. If I can use gnu_get_libc_version() , does that mean for sure that my C program links to glibc? On the other hand, if the linker reports that gnu_get_libc_version() is not found, does that mean for sure that my C program is not linked to glibc?
Is there a function on the Sun libc similiar to gnu_get_libc_version()?
http://docs.sun.com/source/819-3690/Using.Libs.html says "The Solaris operating system comes with several libraries installed in /usr/lib. Most of these libraries have a C interface. Of these, the libc and libm, libraries are linked by the CC driver by default." If one wants to link to the glibc library, how to override the default? How to find out the default? Is it in some environ variable? If one changes the CC driver to gcc, does the default remain the Sun libc? And if one compiles explictly using gcc, i.e. "gcc myprog.c", is the default C library the Sun Library, or glibc?
gnu.org has a (web page for the) glibc manual but I am not able to find a Sun C Library Manual. Is there one?
Edited by: hzmonte on Jun 28, 2008 1:43 AM