Setting up SDL2 in Windows (Visual Studio)

What is the difference between static and dynamic linking?

The lesson mentions 'linking' the SDL libraries to our project. What exactly is linking, and what's the difference between static and dynamic linking?

Abstract art representing computer programming

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.

Free, Unlimited Access

Professional C++

Comprehensive course covering advanced concepts, and how to use them on large-scale projects.

Screenshot from Warhammer: Total War
Screenshot from Tomb Raider
Screenshot from Jedi: Fallen Order
Contact|Privacy Policy|Terms of Use
Copyright © 2024 - All Rights Reserved