Linking is the process of connecting one object code to another object code. Linker is a part of compiler and build tool chain. Compiler generates an object file after a successful compilation of the source file. Application project is often consisting of several source file are compiled separately and then linker makes these object code link together and makes the final executable. Linker calculates the address of each functions/symbols and places in the argument of call or jump instruction.
Modern operating system often support dynamic linking. Here we use a shared library executable code. Application are loaded and the external library routines are linked at the loading or runtime.
There are two main categories of linking - Static Linking and Dynamic Linking.
Static Linking - In this type of linking, linker links the actual code of the library directly into the code section of the executable. Static link library is an archive of several object files. Each object file may contain the executable code of one or more library functions. Linker copies the code and data sections of these object files to the Example: Linking C and Graphics library in Turbo C++ for MS DOS. Linking an application with an archive contains .obj files.
Dynamic Linking - An application may call several library function and linking all those library function in the executable code could impact the size of the overall executable. Again running these executables creates overhead in memory as individual executable loads their own copies of the same library function. Thus to overcome this duplicate copies of code loading, dynamic linking concept came into picture. Dynamic linking does not link the actual code of the external functions. Instead it prepares a list of imported functions in .idata section and a stub code which actually jumps to the external function by address. Dynamic linker is a part of operating system loader. It loads dynamic library executables or DLLs in one shared memory location and links the address of the functions to the application calling locations.
Again Dynamic Linking can be divided into two category. Implicit Dynamic Linking and Explicit Dynamic Linking.
Implicit Dynamic Linking
Implicit Dynamic Linking - Links the code with the import library using .idata section mechanism. At the time of application launching all the dependent DLLs should be loaded to start execution. Also when application ends execution all the dependent DLLs are getting unloaded.
Explicit Dynamic Linking
Explicit Dynamic Linking - This linking does not require any .IMPORT section to list the function entries. It is done at runtime. User calls the Win32 API LoadLibrary() to load a particular DLL from a specific path on the demand basis at runtime. Thus there is no requirement for the DLL to be loaded at the startup time. Also DLL can be unloaded after the use with FreeLibrary() call.
You may also Like
What is implicit and explicit linking in dynamic loading?
How we use dynamic linking in Linux? Give example.
How to call a DLL function from Visual Besic?
How to call a DLL function from java? (Calling C/C++ native function from Java)
About our authors: Team EQA
You have viewed 1 page out of 27. Your DLL learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Calculate weighted average