Librarians Forever

stostat
3 min readMay 11, 2020
Trinity College Library

Can you imagine walking in a library, looking for a specific book but due to some strange reason the whole library is a complete mess, not being organised by topics so you will have to look shelve by shelve to try and find you specific book. That is a whole new level nightmare.

Fortunately since the times of Agora the librarians have created a system to keep the books organised by topic, by subject and even by index so it could be a lot easier for anyone to find whatever book they are looking for.

Well, computers aren’t much far away from this concept and have come up with the same idea, but for its practical purpose, we are able to create libraries where we will save blocks of code that will be used again in different or in the same program.

So imagine you have already access to this piece of code, you won’t have to rewrite it and will save you a lot of time, just like going to a library and knowing exactly where to find the book you are looking for.

So we have our library already, and now we find out we have to choose between two types of libraries, Dynamic libraries and Static libraries, well, lets take a few minutes to figure out which one will work better for us.

Lets start with static libraries, which are actually created along with all the compiled files of the program; in other words, it is locked as part of one program, so it is like wanting to read a book, which you know where to find but you can’t take it home, so you will have to read it inside the library and when the library closes you must leave the book and come back next day when it opens if you want to read it again.

Now in technical terms we will discuss the advantages of static libraries. Since it comes as part of the executable code, which comes already in binary code, its speed will be a lot greater than its counterpart at execution, if you want to modify it, you will have to recompile the whole program again for each time you want to change some part of it. This might look like a drag but this helps keep its libraries safe.

Static vs Dynamic libraries

Now, using the picture above we can talk about dynamic libraries, which as we can see, can be used in multiple programs, it has its own advantages and disadvantages. Its main advantage is its portability, since you can simply share it and use it with a different program, but its execution speed generally takes longer since it has to look for it as an external file.

If this library is modified it could give compilation errors, and sometimes it could be really tiresome to go through the debugging to get to compile successfully the program.

To create a static library we must follow this steps:

1- Create a C file that contains the functions in the library

2- Create a file with the header

3- Compile the file libraries

4- Create the static library

Once created it is ready to use!

The dynamic library doesn’t need to be copied, just needs to be linked when the program runs.

And if any doubt remains, a good old friend this may explain.

--

--