guest
guest

Reputation:

Difference between load-time and run-time dynamic linking

What is the difference between Load-time dynamic linking and Run-time dynamic linking?

Upvotes: 9

Views: 7281

Answers (3)

Sweekritee Singh
Sweekritee Singh

Reputation: 182

Load time dynamic linking is performed by Operating System when an application is loaded. OS uses the information linker has placed in the file to locate the names of the dll, and then searches for those dlls, And if it fails to locate the Dll, it simply terminates and gives error message, otherwise, OS maps the DLL into the virtual address space of the process and increases the DLL reference count.

Upvotes: 0

jussij
jussij

Reputation: 10560

Load-time Dynamic Linking

When an executable is linked to a DLL at build time the linker will not insert object code but rather it insert a stub which basically says a function of this name is located in this DLL.

Now when the executable is run, bits of the executable will be missing (i.e the function stubs) so before the program is allowed to run the program loader fixes up these missing functions by replacing them with entry points into the DLL files.

Only after all the stubs have been replace (i.e resolved) will the executable be allowed to run.

That is load time dynamic linking.

Run-time Dynamic Linking

In this case the executable was not linked to any DLL library file, so it will not contain any stubs into the dll and as such the program loader has no issue running the executable.

But the task of getting access to the function from with-in the DLL is left to the executable and can be done using the GetProcAddress Windows API.

That is run time dynamic linking.

Upvotes: 17

Ken White
Ken White

Reputation: 125728

You forgot the "homework" tag.

Load-time linking means that the DLL you're linking to is loaded when your application starts, regardless of whether or not you actually use the functionality in that DLL. Dynamic linking means that the functionality of the DLL is only loaded when it's actually needed.

Upvotes: 3

Related Questions