Member-only story

What are static libraries in “C” ?

Connor Brereton
4 min readOct 9, 2018

--

Some background context..

A static library is a single collection of object code files (created during the compilation process) that speeds up the creation of a program’s executable file, in particular, during the linking phase. However, they make files really large because the entire library is linked to the executable file unlike dynamic libraries that are mapped into the process during runtime.

In C, the static library can be seen in the /usr/lib/ directory of your Linux operating system. Static libraries are also known as archives, and I think that the naming has something to do with the definition of an archive —a collection of historical documents or records providing information.

Libraries have the .a extension and lib as a prefix before the library name so naturally it makes sense that the C library is libc.a.

You can inspect a library by typing

ar -t <archive> into your terminal.

The ar command creates, modifies, or extracts from archives.

The -t flag displays a table listing the contents of the archive.

The library needed to accomplish such as task is the standard input/output library. See below for an example.

--

--

Connor Brereton
Connor Brereton

Responses (1)