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 Linux 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 in 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 if made up of a set of routines, external functions and variables. After locking into a program at compile time, it 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 below output 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 one copy of the library’s files.

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.

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

The files with the .so extension are nothing but 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 on my Ubuntu machine.


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

.la files

The files with the .la extension are not libraries but in fact they are textual files that include a description of the library. They are generated by the GNU “libtools” package and are used to describe the files that make up the corresponding libraries.