Static library VS Dynamic library

I have problems to differentiate the meaning and uses of all these “static”, “dynamic”, “library”. I’m somehow understand it but I will soon confused over time all over again the next time I encounter them. Never do a deep research on this until… I have to build a new library to give API’s to developer in my work. (No escape 🙂

Here is a nice analogy I read online to help me remember them:

A static library is like a bookstore, and a shared library is like… a library. With the former, you get your own copy of the book/function to take home; with the latter you and everyone else go to the library to use the same book/function. So anyone who wants to use the (shared) library needs to know where it is, because you have to “go get” the book/function. With a static library, the book/function is yours to own, and you keep it within your home/program, and once you have it you don’t care where or when you got it.

Static library

A static library, also known as an archive, is one intended to be statically linked

Static library,also known as an archive, is one intended to be statically linked. The file format is .a file in iOS (.lib in Android) is linked into the program at compile time which means there is no additional run-time loading costs. Although it is added on app binaries size, it is able to ensure dependencies of the libraries are able to be met.

– .a files in iOS (.lib in Android)

– Used at compile time

– Linked all the archive files and connected along with all your implementation files

– Include into executable file size

static library

Dynamic library

If you wonder why Apple restricted dynamic library to iOS but not to Mac, read this. Dynamic library can be loaded or unloaded its code at run-time. Dynamic libraries are .dylib files in iOS (.so in Android). A program using a dynamic library only makes reference to code that it uses in the dynamic library.

– .dylib (iOS) OR .so (Android)

– Used at run-time (therefore it reduced launch time)

– Reduced the amount of code that duplicated in each program by keeping the binaries small


dynamic library





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s