Chapter 8. Static and Dynamic Libraries: Hot-swappable code

You’ve already seen the power of standard libraries.
Now it’s time to use that power for your own code. In this chapter, you’ll see how to create your own libraries and reuse the same code across several programs. What’s more, you’ll learn how to share code at runtime with dynamic libraries. You’ll learn the secrets of the coding gurus. And by the end of the chapter, you’ll be able to write code that you can scale and manage simply and efficiently.
Code you can take to the bank
Do you remember the encrypt() function you wrote a while back that
encrypted the contents of a string? It was in a separate source code
file that could be used by several programs:

Somebody else has written a function called checksum() that can be used to check if the
contents of a string have been modified. Encrypting data and checking if
data has been modified are both important for security. Separately, the two functions are
useful, but together they could form the basis of a security library.


Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access