ash
ash

Reputation: 3474

dlls: static vs implicit linking, same thing?

Concerning Dll linkage, are static and implicit linking the same thing?

I understand the difference between implicit and explicit linking, and I think static is synonymous with implicit, but am not certain.

if they are indeed different, what is the difference between them, and how do I specify which one I want?

this link from msft uses the term "implicit" for what I've heard referred to as "static". Is it perhaps a msft-specific thing?

Upvotes: 4

Views: 1768

Answers (2)

David Heffernan
David Heffernan

Reputation: 612784

Yes, in Windows-land, when discussing linking to DLLs, the terms static linking and implicit linking are synonymous.

The Visual Studio documentation calls this out:

Implicit linking is sometimes referred to as static load or load-time dynamic linking. Explicit linking is sometimes referred to as dynamic load or run-time dynamic linking.

In days gone by Microsoft preferred the terms implicit and explicit linking. Nowadays they seem to prefer the terms load-time and run-time, respectively. All the same, when people talk about linking to DLLs, the term static means is synonymous with implicit and load-time.

I for one try to avoid using static in relation to DLL linking for a couple of reasons:

  1. It's easy to get mixed up with linking to a static library.
  2. The idea that one might link statically to something that is dynamic just feels oxymoronic.
  3. The term static is already used to mean who knows how many different things in the C and C++ languages and I'd rather not overload the term any more than it already is!

Upvotes: 4

anotherdev
anotherdev

Reputation: 2569

Implicit linking could be done with static (.a) or dynamic libraries (.so, .dll). When you compile a program with link to the library, it's an implicit linking. It's faster thant an explicit linking.

An explicit linking is when you use dlopen with dynamic libraries (.so, .dll). You don't compile the program with the link to the library, but you use dlopen to open the file, and you extract the functions you need.

Upvotes: 2

Related Questions