Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Where are libc files located

When I write code such as

#include <stdio.h>

int main(int argc, char** argv) {
    printf("Hello, world!\n");
    return 0;
}

gcc imports stdio.h which in turn requires an associated stdio.c where the functions are defined. I know on linux stdio.h is located in /usr/include/stdio.h but where is stdio.c? There is no /usr/include/stdio.c but, obviously, gcc can compile this code just fine.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

libc, like most libraries, is compiled ahead of time and shipped with your system as a compiled library rather than as source code. On Linux, that library will be called libc.a (for static linking) or libc.so (for dynamic linking), and can usually be found in /usr/lib or one of its subdirectories.

Also, note that in C there is actually no requirement that the header file name match that of the source file. For example, glibc, one of the most popular implementations of libc, scatters its stdio implementation across several files (approximately one C file for each function in stdio).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading