There is more

It is good practice to hide internal symbols when building a shared library. This means that the library shrinks in size, because what you expose to the user is less than what you have in the library. This defines the Application Binary Interface (ABI), which most of the time should coincide with the Application Programming Interface (API). This is done in two stages:

  1. We use the appropriate compiler flags.
  2. We mark symbols to be exported with a preprocessor variable (message_EXPORT, in our example). When compiling, the hiding will be lifted for these symbols (such as classes and functions).

Static libraries are just archives of object files. Thus one compiles sources into object files and then the archiver bundles them into ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.