What is GLIBC? What is it used for?

user1261015 picture user1261015 · Jul 12, 2012 · Viewed 45.6k times · Source

I was searching for the source code of the C standard libraries. What I mean with it is, for example, how are cos, abs, printf, scanf, fopen, and all the other standard C functions written, I mean to see their source code.

So while searching for this, I came across with GLIBC, but I don't know what it actually is. It is GNU C Library, and it contains some source codes, but what are they actually, are they the source code of the standard functions or are they something else? And what is it used for?

Answer

Aftnix picture Aftnix · Jul 12, 2012

Its the implementation of Standard C library described in C standards plus some extra useful stuffs which are not strictly standard but used frequently.

Its main contents are :

1) C library described in ANSI,c99,c11 standards. It includes macros, symbols, function implementations etc.(printf(),malloc() etc)

2) POSIX standard library. The "userland" glue of system calls. (open(),read() etc. Actually glibc does not "implement" system calls. kernel does it. But glibc provides the user land interface to the services provided by kernel so that user application can use a system call just like a ordinary function.

3) Also some nonstandard but useful stuff.

"use the force, read the source "

$git clone git://sourceware.org/git/glibc.git

(I was recently pretty enlightened when i looked through malloc.c in glibc)