What is GLIBC? What is it used for?

CGnuGlibcStandard Library

C Problem Overview


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?

C Solutions


Solution 1 - C

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)

Solution 2 - C

There are several implementations of the standard. Glibc is the implementation that most Linuxes use, but there are others. Glibc also contains (as Aftnix states) the glue functions which set up the scene for jumps into the kernel (also known as system calls). So many of glibc's 'functions' don't do the actual work but only delegate to the kernel.

To read the source of Glibc, just google for it. There are myriad sites which carry it, and also several variations.

Windows uses Microsoft's own implementation, which I believe is called MSVCR.DLL. I doubt that you will find the source code to that library anywhere. Also note that some functions which a Linux hacker might think of as 'standard', simply don't exist on Windows (notably fork). The reverse is also true.

Other systems will have their own libc.

Solution 3 - C

The glibc package contains standard libraries which are used by multiple programs on the system. In order to save disk space and memory, as well as to make upgrading easier, common system code iskept in one place and shared between programs. This particular package contains the most important sets of shared libraries: the standard C library and the standard math library. Without these two libraries, a Linux system will not function. The glibc package also contains national language (locale) support.

Solution 4 - C

Yes, It's the implementation of standard library functions.

More specifically, it is the implementation for all GNU systems and in almost all *NIX systems that use the Linux kernel.

Solution 5 - C

Here are a few "hands-on" points of view:

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1261015View Question on Stackoverflow
Solution 1 - CAftnixView Answer on Stackoverflow
Solution 2 - CjforbergView Answer on Stackoverflow
Solution 3 - CSandyView Answer on Stackoverflow
Solution 4 - Cuser529758View Answer on Stackoverflow
Solution 5 - CCiro Santilli Путлер Капут 六四事View Answer on Stackoverflow