Dynamic Link Library (DLL) and C (Run time)

Before we start about Dynamic Link Library (DLL), there are few question which pop-up in my mind are:
  1. What does Library means in Computer?
  2. If there is any Library available then how to create or maintain it?
  3. Does the Library file is portable on Cross Platform?

What does Library means in Computer?

In English the Library means a collection of books, a place where a large number of books are placed and in Computer it means the collections of functions. With these functions any body can read and write other functions. The use of Library files are mostly done by IDE Development Environment, as which these Libraries provide the static structure to all same perfectness and can be used simultaneously by many programs such as Library used by many people’s.

History about Library

The earliest programming concepts of libraries were intended to separate data definitions from the program implementation. “COMPOOL” (Communication Pool) concept to popular attention in 1959, although it adopted the idea from the large-system SAGE software.
Another major contributor to the modern library concept came in the form of the sub-program innovation of FORTRAN. FORTRAN sub-programs can be compiled independently of each other, but the compiler lacks a linker. So prior to the introduction of modules in Fortran-90, type checking between sub-programs was impossible.
Finally, historians of the concept should remember the influential Simula 67. Simula was the first object-oriented programming language, and its classes are nearly identical to the modern concept as used in Java, C++, and C#. The class concept of Simula was also a progenitor of the package in Ada and the module of Modula-2. Even when developed originally in 1965, Simula classes could be included in library files and added at compile time.

If there is any Library available then how to create or maintain it

Libraries contain code and data that provide services to independent programs. This encourages the sharing and changing of code and data in a modular fashion, and eases the distribution of the code and data. Some executables are both standalone programs and libraries, but most libraries are not executable. Executables and libraries make references known as links to each other through the process known as linking, which is typically done by a linker. Most compiled languages have a standard library although programmers can also create their own custom libraries. Most modern software systems provide libraries that implement the majority of system services. Such libraries have commonality services which a modern application requires. As such, most code used by modern applications is provided in these system libraries.
Some programming languages may use a feature called smart linking wherein the linker is aware of or integrated with the compiler, such that the linker knows how external references are used, and code in a library that is never actually used, even though internally referenced, can be discarded from the compiled application. For example, a program that only uses integers for arithmetic, or does no arithmetic operations at all, can exclude floating-point library routines. This smart-linking feature can lead to smaller application file sizes and reduced memory usage.

Does the Library file is portable on Cross Platform?

So, we can say that Libraries are important in the program linking or binding process, which resolves references known as links or symbols to library modules. The linking process is usually automatically done by a linker or binder program that searches a set of libraries and other modules in a given order. Usually it is not considered an error if a link target can be found multiple times in a given set of libraries. Linking may be done when an executable file is created, or whenever the program is used at run time.
When linking is performed during the creation of an executable or another object file, it is known as static linking or early binding. In this case, the linking is usually done by a linker, but may also be done by the compiler. A static library, also known as an archive, is one intended to be statically linked. Originally, only static libraries existed. Static linking must be performed when any modules are recompiled.
For Cross Platform, it is dependable on Compiler, if the Compiler supports the cross-platform Compiling then the Library Created in One Platform is used on Another Platform. Generally, this feature is available in every compiler but not used to make the compiler the O/S specific but with changing some of the options, one can compile the program for cross Platform. The best Example of this is C Language Programs the programs such as MySQL, PHP, Apache are used as cross-platform and Libraries created by them are also portable to cross-platform but certainly a tweak is required to generate that type of code and it has many Rules. To know about rules kindly refer to Manual of your Compiler.

Differences Between Applications and DLLs

Even though DLLs and applications are both executable program modules, they differ in several ways. To the end-user, the most obvious difference is that DLLs are not programs that can be directly executed. From the system’s point of view, there are two fundamental differences between applications and DLLs:
  1. An application can have multiple instances of itself running in the system simultaneously, whereas a DLL can have only one instance.
  2. An application can own things such as a stack, global memory, file handles, and a message queue, but a DLL cannot.

Advantages of Using DLLs

  1. Saves disk space. Many applications can share a single copy of the DLL on disk. In contrast, each application built with a static link library has the library code linked into its executable image as a separate copy.
  2. Saves memory and reduces swapping. Many processes can use a single DLL simultaneously, sharing a single copy of the DLL in memory. In contrast, Windows must load a copy of the library code into memory for each application that is built with a static link library.
  3. Upgrades to the DLL are easier. When the functions in a DLL change, the applications that use them do not need to be recompiled or re-linked as long as the functions’ arguments and return values do not change. In contrast, statically linked object code requires that the application be re-linked when the functions change.
  4. Provides after-market support. For example, a display driver DLL can be modified to support a display that was not available when the application was shipped.
  5. Supports multi language programs. Programs written in different programming languages can call the same DLL function as long as the programs follow the function’s calling convention. The programs and the DLL function must be compatible in the following ways: the order in which the function expects its arguments to be pushed onto the stack, whether the function or the application is responsible for cleaning up the stack, and whether any arguments are passed in registers.
  6. Provides a mechanism to extend the MFC library classes. You can derive classes from the existing MFC classes and place them in an MFC extension DLL for use by MFC applications.
  7. Eases the creation of international versions. By placing resources in a DLL, it is much easier to create international versions of an application. You can place the strings for each language version of your application in a separate resource DLL, and have the different language versions load the appropriate resources.


A potential disadvantage to using DLLs is that the application is not self-contained; it depends on the existence of a separate DLL module.

Linking an Executable to a DLL

An executable file links to (or loads) a DLL in one of two ways:
  1. Implicit linking.
  2. Explicit linking.
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. With implicit linking, the executable using the DLL links to an import library (.LIB file) provided by the maker of the DLL. The operating system loads the DLL when the executable using it is loaded. The client executable calls the DLL’s exported functions just as if the functions were contained within the executable.
With explicit linking, the executable using the DLL must make function calls to explicitly load and unload the DLL, and to access the DLL’s exported functions. The client executable must call the exported functions through a function pointer. An executable can use the same DLL with either linking method. Furthermore, these mechanisms are not mutually exclusive, as one executable can implicitly link to a DLL and another can attach to it explicitly.

Using Linking Implicitly

To implicitly link to a DLL, executables must obtain the following from the provider of the DLL:
A header file (.H file) containing the declarations of the exported functions and/or C++ classes.
An import library (.LIB files) to link with. The linker creates the import library when the DLL is built.

The actual DLL (.DLL file).

Executable’s using the DLL must include the header file containing the exported functions (or C++ classes) in each source file that contains calls to the exported functions. From a coding perspective, the function calls to the exported functions are just like any other function call. To build the calling executable file, you must link with the import library. If you are using an external Makefile, specify the file name of the import library where you list other object (.OBJ) files or libraries that you are linking with. The operating system must be able to locate the .DLL file when it loads the calling executable.

Using Linking Explicitly

With explicit linking, applications must make a function call to explicitly load the DLL at run time. To explicitly link to a DLL, Call LoadLibrary() (or a similar function) to load the DLL and obtain a module handle and Call GetProcAddress() to obtain a function pointer to each exported function that the application wants to call. Because applications are calling the DLL’s functions through a pointer, the compiler does not generate external references, so there is no need to link with an import library. Call FreeLibrary() when done with the DLL.
Tagged , , ,

38 thoughts on “Dynamic Link Library (DLL) and C (Run time)

  1. Page Sarvas says:

    Hello there! This post couldn’t be written any better! Reading this post reminds me of my previous room mate! He always kept chatting about this. I will forward this article to him. Pretty sure he will have a good read. Many thanks for sharing!

  2. I like this website very much, Its a very nice billet to read and incur information.

  3. The more I read this blog the more time I’d like to have to spend here

  4. I like this blog it’s a master piece! Glad I noticed this on google.

  5. I regard something really interesting about your web site so I saved to my bookmarks .

  6. It is the best time to make a few plans for the future and it is time to be happy. I have read this submit Dynamic Link Library (DLL) and C (Run time) Vineet Gupta and if I may just I desire to suggest you few interesting things or tips. Perhaps you can write subsequent articles regarding this article. I want to learn more issues approximately it!

    • Vineet Gupta says:

      I would definitely provide more information on this subject. Its only the starting things of my blog and as time passes more and more information would be provided with real issue’s solutions. Thanks for posting a comment..

  7. Thankyou for helping out, superb information.

  8. Free Cam sex says:

    Wohh precisely what I was searching for, regards for posting.

  9. You have mentioned very interesting points! ps decent website.

  10. piano cat says:

    I haven’t checked in here for a while since I thought it was getting boring, but the last few posts are good quality so I guess I’ll add you back to my daily bloglist. You deserve it my friend 🙂

  11. I like this web blog it’s a master piece! Glad I observed this on google.

  12. I was studying some of your articles on this site and I believe this internet site is real informative! Keep on putting up.

  13. site says:

    I truly appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thanks again!

  14. I like this web blog very much, Its a rattling nice berth to read and find information.

  15. Very interesting subject , regards for posting .

  16. Deandrea says:

    I like this web blog it’s a master piece! Glad I noticed this on google.

  17. I was reading through some of your posts on this site and I conceive this web site is really instructive! Keep posting.

  18. Scrapebox says:

    I was examining some of your posts on this website and I conceive this site is really informative ! Keep putting up.

  19. I view something truly interesting about your web blog so I bookmarked .

  20. Nila says:

    I like this post, enjoyed this one thanks for putting up.

  21. I will immediately grab your rss as I can’t find your e-mail subscription link or e-newsletter service. Do you’ve any? Please permit me understand so that I may subscribe. Thanks.

    • Vineet Gupta says:

      You can subscribe notification of new post through Email and thus created the Follow box at the bottom i.e. after comments box to provide email address or you can click on the follow button provided to follow the notifications of new posts.

  22. Sharita says:

    I conceive this website has got very good composed content posts.

  23. Perfectly pent subject matter, thankyou for selective information .

  24. I found your blog web site on google and examine a number of of your early posts. Continue to maintain up the excellent operate. I just extra up your RSS feed to my MSN Information Reader. In search of ahead to reading more from you later on!…

  25. I just like the helpful info you provide for your articles. I’ll bookmark your blog and test again here frequently. I’m slightly sure I will learn many new stuff right here! Good luck for the next!

  26. Great post, I conceive people should learn a lot from this web site its really user friendly. So much wonderful info on here :D.

  27. A person necessarily help to make severely articles I’d state. That is the first time I frequented your web page and thus far? I surprised with the analysis you made to create this actual submit amazing. Wonderful task!

  28. Just want to say your article is as amazing. The clarity to your submit is just nice and that i can think you’re knowledgeable on this subject. Fine together with your permission allow me to take hold of your RSS feed to stay up to date with coming near near post. Thanks one million and please carry on the rewarding work.

  29. Perfectly pent written content , regards for entropy.

  30. But wanna comment that you have a very decent internet site , I enjoy the style it really stands out.

  31. Sexchat says:

    I always was interested in this topic and stock still am, regards for putting up.

  32. Hello! I could have sworn I’ve been to this web site before but after browsing through some with the post I realized it is new to me. Nonetheless, I’m definitely pleased I identified it and I’ll be book-marking and checking back frequently!

  33. gamefaqs says:

    Some really superb posts on this website , appreciate it for contribution.

  34. etupakka says:

    You are my inhalation , I own few blogs and infrequently run out from to post .

  35. I wanted to thank you once again for that amazing blog you have created here. It can be full of useful tips for those who are genuinely interested in that subject, especially this very post. You’re really all so sweet and thoughtful of others plus reading the blog posts is a great delight in my experience. And what a generous reward! Jeff and I are going to have enjoyment making use of your points in what we should do in a month’s time. Our list is a kilometer long and tips will certainly be put to beneficial use.

  36. Thanks so much regarding giving my family an update on this theme on your website. Please realise that if a brand-new post appears or if any modifications occur with the current submission, I would be thinking about reading a lot more and learning how to make good using of those strategies you talk about. Thanks for your time and consideration of other people by making this site available.

Comments are closed.

%d bloggers like this: