xdevel2000
xdevel2000

Reputation: 21444

C standard library and object files

I know that every header file, i.e. string.h, should have an object file in which there is the proper implementation.

I also know that for GCC and glibc there is a libc.a or libc.so containing object files.

I tried to open libc.a to see if I could find, i.e., string.o but I didn't find it.

Why? Where can I find for every header the correspondent object file?

Upvotes: 1

Views: 626

Answers (2)

Serge Ballesta
Serge Ballesta

Reputation: 149145

It may be implementation dependant. A single .h file may correspond to many .o or the opposite, you might have many .h for a single .o

For example, in my libc.a, I can see about one module per string function :

$ ar t libc.a | grep '^str' | sort
strcasecmp.o
strcasestr.o
strcat.o
strchr.o
strcmp.o
strcoll.o
strcpy.o
strcspn.o
strdup.o
strerror.o
strfmon.o
strftime.o
stringlist.o
strlcat.o
strlcpy.o
strlen.o
strmode.o
strncat.o
strncmp.o
strncpy.o
strndup.o
strnlen.o
strnstr.o
strpbrk.o
strptime.o
strrchr.o
strsep.o
strsignal.o
strspn.o
strstr.o
strtofflags.o
strtoimax.o
strtok.o
strtol.o
strtoll.o
strtonum.o
strtoq.o
strtoul.o
strtoull.o
strtoumax.o
strtouq.o
strxfrm.o

Upvotes: 2

Sourav Ghosh
Sourav Ghosh

Reputation: 134386

well, in my system, libc.so shows up in /lib

[sourav@braodsword temp]$ ls -l /lib/libc*
-rwxr-xr-x 1 root root 1611564 Mar 10  2010 /lib/libc-2.5.so

However, if you're looking for the source code, you'll not find that in .so file, anyway.

Again, don't expect, every header file declaration will have a defferent object file. They are taken together to form the shared library .so.

Upvotes: 0

Related Questions