As far as I understand they are libraries, but what is the difference between the two?


2 Answers 2


A .a file is a static library, while a .so file is a shared object (dynamic) library similar to a DLL on Windows. There's some detailed information about the differences between the two on this page.

  • 30
    .a can only be included as part of a program during compiling. .so's can be "imported" while a program loads.
    – LawrenceC
    Commented May 14, 2011 at 23:39
  • 5
    what does .a stand for?
    – hfrmobile
    Commented Nov 29, 2016 at 12:17
  • 10
    @hfrmobile The a stands for archive - a static library is a collection of object files created using the ar utility. More info here
    – ajk
    Commented Nov 29, 2016 at 16:19

As a follow on, a .a file is an "ar" archive. Not unlike a tar archive, it stores .o or object files, allowing them to be pulled out of the archive, and linked into a program, among other things. You could use ar to store other files if you wanted.

You can get a listing of the members of an ar file with the -t parameter, for instance:

ar -t /usr/lib/libc.a

A .so file is a "shared object" file, and has a lot more information available to the linker so that members can be linked in to a loading program as rapidly as possible.

For instance, try:

objdump -T /lib/libc-2.11.1.so

(or whatever version of libc.so you have in your /lib directory.) Note that a .so file could also just contain a linker script directing it to find the file elsewhere, or use something else.

Interestingly, a .so file can also be a full fledged program. For instance, trying running /lib/libc.so.6. (This works on my Ubuntu 20.04 system)

  • Typo. you mean to write ar -t /usr/lib/libc.a. Actually the - doesn't seem to be necessary in this case. Also /lib/libc.so.6. just prints some output. I don't know if I would call it a full fledged program. Commented May 15, 2011 at 8:09
  • 1
    It's a full fledged program in the sense that it has a main symbol for exec to find.
    – Hack Saw
    Commented May 16, 2011 at 16:05
  • 3
    You can also run ldd on .so's, and it will show you what other libraries it uses. Static will return with a message saying it's not a dynamic library.
    – Marcin
    Commented May 17, 2011 at 1:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .