0

I guess my question is very straightforward, I cannot see the whole picture when using dynamic linking (either load-time or run-time) on programs since I wonder how the linker behaves at compile time when it sees unresolved references and do not find any definitions for them (cause they are on the dll files), but anyway the program compiles fine, even when there are references that will be resolved until run-time.

It is supposed the linker needs to resolve every reference at compile time in order to be okay (as it happens with static-linking), so when working when dll files, in some way, the linker says it is okay to leave those references unresolved to be resolved after on run-time (I guess we as programmers tell the linker to think like that with code, like saying some functions are on dll files as we say the compiler some functions exist somewhere when using forward-declarations).

Can some one explain me what is the step by step process for how the linker behaves at compile time when it sees there are external references to dll files for both load-time and run-time dynamic linking strategies?

In particular when working with dll files on C++, so I could understand what pieces of code tell the linker to behave like that.

Sidenote:

I already made my research online on microsoft docs and other sites but I did not understand everything at all, so I turned here.

Wolf
  • 9,679
  • 7
  • 62
  • 108
  • The way an exe file is loaded is not as trivial as one may think. Maybe this article could help clarifying: [Loading a DLL from memory » ~magog/public](https://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/) – Wolf Jan 15 '21 at 22:52
  • 2
    [This answer](https://stackoverflow.com/a/56086105/10871073) from Remy Lebeau gives a very good summary of the process, IMHO. – Adrian Mole Jan 15 '21 at 23:03

1 Answers1

0

how the linker behaves at compile time when it sees unresolved references

It doesn't just see "unresolved references" - you'll get errors if the references are really unresolved. It needs to have access to a dynamic library (or, on windows, a so-called import library) that declares those symbols and lets the linker know what libraries to get them from. The linker then produces executable that has references to the dynamic libraries that provide those symbols.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313