NO

Author Topic: How is static linking decided vs dynamic linking?  (Read 2606 times)

x79

  • Guest
How is static linking decided vs dynamic linking?
« on: March 08, 2015, 05:49:17 PM »
I hope I am asking the right question.
As I understand, Statically linked means the lib is part of the compiled exe and dynamically linked means that the compiled exe will call an external library for the linked functions.

If I am correct, how does Poide know that I want my custom lib to be statically linked but others like shell32.lib and kernel32.lib to be dynamically linked?

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: How is static linking decided vs dynamic linking?
« Reply #1 on: March 08, 2015, 06:16:41 PM »
Because when you use a DLL the pseudo lib you link forwards the link to the dynamic library.
Objects as shell32.lib and kernel32.dll are pseudolibs, that create entries in the import section of the executable PE file.
The OS loader scans the import section, load DLL in the process memory and copy required functions entry address in the bind table.
Your program when calls a DLL function points to the bind table then jumps to the DLL entry loaded in the process space.
When you create a new DLL with PellesC, or any other compiler, the linker creates also a pseudolib for the dynamic linking.
« Last Edit: March 08, 2015, 06:19:18 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

x79

  • Guest
Re: How is static linking decided vs dynamic linking?
« Reply #2 on: March 08, 2015, 08:05:59 PM »
great info. tyvm