Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Location of C standard library

Tags:

c

gcc

In the gcc manual it is given that "The C standard library itself is stored in ‘/usr/lib/libc.a’". I have gcc installed, but could not find libc.a at the said location. Curious to know where is it located.

I find many .so files in /usr/lib location. What are those?

like image 418
softwarematter Avatar asked May 08 '11 04:05

softwarematter


People also ask

Where is C standard library located?

The C standard library itself is stored in '/usr/lib/libc.

Is there a standard library for C?

The C standard library or libc is the standard library for the C programming language, as specified in the ISO C standard. Starting from the original ANSI C standard, it was developed at the same time as the C library POSIX specification, which is a superset of it.

Where is C standard library Macos?

On Mac and iOS the C Standard Library implementation is part of libSystem, a core library located in /usr/lib/libSystem.

What is standard library function in C?

Library functions are built-in functions that are grouped together and placed in a common location called library. Each function here performs a specific operation. We can use this library functions to get the pre-defined output. All C standard library functions are declared by using many header files.


2 Answers

If you are looking for libc.a:

$ gcc --print-file-name=libc.a /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libc.a 
like image 66
rscohn2 Avatar answered Oct 06 '22 12:10

rscohn2


A few things:

  • gcc and glibc are two different things. gcc is the compiler, glibc are the runtime libraries. Pretty much everything needs glibc to run.
  • .a files are static libraries, .so means shared object and is the Linux equivalent of a DLL
  • Most things DON'T link against libc.a, they link against libc.so

Hope that clears it up for you. As for the location, it's almost certainly going to be in /usr/lib/libc.a and / or /usr/lib/libc.so. Like I said, the .so one is the more common.

like image 33
Chris Eberle Avatar answered Oct 06 '22 12:10

Chris Eberle