Understanding .a , .so and .la library files in Linux

In order to understand what the libraries of files with the extensions .a, .so and .la actually mean, we first must be aware of the concept of libraries in Linux. A library in its very simple terms is a collection of pre-compiled pieces of code which are known as functions. Libraries are very useful as they provide reusable functions, classes and data structures. Some examples of libraries in Linux are glibc (GNU version of standard C library), libc (the C standard library).

In total we can divide the libraries in Linux into two categories. These categories are −

  • Static Libraries

  • Dynamic Libraries

Static Libraries

The libraries that are locked into a program at compile time are known as static libraries. They are also known as statically-linked libraries and are made up of a set of routines, external functions and variables. After locking into a program at compile time, the library code is then copied to a target application by a linker, binder or compiler, which in turn produces an object file and a stand-alone executable.

These types of libraries are faster than the shared libraries as a set of object files that are commonly used is put into a single library executable file. The downside of using a static library is that the code that is used to build it is locked into the final executable and it cannot be modified without re-compiling the library.

The static libraries have a .a extension, where the .a stands for "archive" and the output below shows some of the static libraries inside the Go source code −

immukul@192 darwin_amd64 % ls -tlr
total 49376
-rw-r--r-- 1 root wheel 356788 Apr 1 23:13 unicode.a
-rw-r--r-- 1 root wheel 1023672 Apr 1 23:13 time.a
-rw-r--r-- 1 root wheel 1534494 Apr 1 23:13 syscall.a
-rw-r--r-- 1 root wheel 288140 Apr 1 23:13 sync.a
-rw-r--r-- 1 root wheel 501654 Apr 1 23:13 strings.a
-rw-r--r-- 1 root wheel 537834 Apr 1 23:13 strconv.a
-rw-r--r-- 1 root wheel 227774 Apr 1 23:13 sort.a

Dynamic Libraries

Libraries that exist as separate files outside of the executable files are known as dynamic libraries. At compile time, the program makes only a reference to the library's functions, not a complete copy. The actual library code is loaded into memory at runtime when the program executes.

The benefit of using a dynamic library is that one single library can be used by multiple applications without the need for each application to have its own copy of the library like we have in case of the static libraries. This saves disk space and memory usage.

The downside of a dynamic library is that the chances of breaking are much higher compared to a static library. A simple case would be that if a dynamic library becomes corrupt or is missing, the executable file may no longer work.

The files with the .so extension are dynamic libraries and the suffix ".so" stands for shared object. Consider the output shown below that denotes some of the dynamic libraries present inside the /usr/lib folder −

lrwxr-xr-x 1 root wheel 27 Jan 1 2020 libhunspell-1.2.0.so
-rwxr-xr-x 1 root wheel 177440 Jan 1 2020 libgmalloc.so
-rwxr-xr-x 1 root wheel 104112 Jan 1 2020 libffi-trampolines.so
-rwxr-xr-x 1 root wheel 2851232 Jan 1 2020 libMTLCapture.so
-rwxr-xr-x 1 root wheel 137824 Jan 1 2020 libLeaksAtExit.so

Libtool Archive Files (.la)

The files with the .la extension are not libraries but are in fact textual files that include a description of the library. They are generated by the GNU libtool package and are used to describe the files that make up the corresponding libraries. These files contain metadata about the library, including dependencies and linking information.

A typical .la file contains information such as the library name, version, dependencies, and paths to the actual library files. This helps the build system understand how to link against the library properly.

Comparison

Library Type Extension Linking Memory Usage Performance
Static Library .a Compile-time Higher (copy per executable) Faster execution
Dynamic Library .so Runtime Lower (shared among processes) Slightly slower loading
Libtool Archive .la Build metadata Minimal (text file) Not applicable

Conclusion

Understanding the differences between .a, .so, and .la files is essential for Linux development. Static libraries provide faster execution but consume more space, while dynamic libraries offer better resource efficiency and modularity. Libtool archive files serve as metadata containers to facilitate proper library linking and dependency management.

Updated on: 2026-03-17T09:01:38+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements