What’s in a Library?

A library is essentially a file that contains compiled object modules (a module is the object file produced from compiling a single source file). A program can call, or import, routines and access data defined in another library. Such libraries can contain numeric analysis functions, multimedia packages, graphics, etc. There are two main categories of libraries: static and dynamic. When you link your code with a static library, the program copies the code and data it needs from that library into the executable file. Thus, a statically linked program that uses the printf() function contains a copy of this function in its executable file. By contrast, a dynamic library (or runtime library) is linked to a program at runtime: references to functions and data from the runtime library are resolved at runtime and are not copied into the program’s executable file.

Most C and C++ implementations provide a runtime library which contains the standard functions and data structures of the language (e.g., the printf() function, operator new and delete, iostream objects, etc.). A runtime library is usually shared?all processes and applications on the same machine share a single copy instead of having multiple copies of the same library code. A runtime library offers three advantages compared to a statically linked one:

  • It reduces the program’s size because the library’s code is not included in the program’s executable file
  • Changes made to the runtime library (e.g., an upgrade, bug fixes) don’t require that the programs be relinked; the next time you run the program, it automatically loads the new library version and accesses its code and data.
  • It saves considerable amount of disk space because its code is shared rather than being copied into each program file.

That said, dynamic libraries can also cause serious difficulties if several programs depend on the same library, and the library is changed (this problem is know as the “DLL hell” in windows, although other platforms suffer from this problem, too). Additionally, the runtime overhead of dynamic linking is considerable and slows down execution speed.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet

payment via phone

7 Ways Technology Has Changed Traditional Payments

In today’s digital world, technology has changed how we make payments. From contactless cards to mobile wallets, it’s now easier to pay for goods and services without carrying cash or using a checkbook. This article will look at seven of the most significant ways technology has transformed traditional payment methods.