Linking is the process of combining the object files generated during compilation into a single executable file. The linker resolves symbolic references between object files and library files.
There are two ways a library can be linked to an application - statically or dynamically:
Static linking means the library code is copied into the executable at compile time. The advantage is that the executable is self-contained and can run on its own. The disadvantages are that the executable is larger, and if the library is updated, the application needs to be recompiled.
Dynamic linking means the library code is not copied into the executable. Instead, the executable contains a reference to the library, which is resolved at runtime. The advantages are smaller executable size and the ability to update the library without recompiling the application. The main disadvantage is that the required .dll or .so files must be present on the user's system.
In general, dynamic linking is more flexible and is used by most modern libraries and applications. Static linking is mainly used in embedded systems or where absolute minimum dependencies are required.
Answers to questions are automatically generated and may not have been reviewed.
A step-by-step tutorial on configuring SDL2, SDL_image and SDL_ttf in a Visual Studio C++ project on Windows