The help you needed in C, C++, MFC
Complete tutorials with free source code

Creating library modules

Library modules contain compiled code, like an executable program. But, they cannot run by themselves, instead they are attached by other executable files and the functionality in the library modules can then be used by the executable.

There are 2 types of libraries, dynamically linked libraries (dll) and statically linked libraries (lib). The statically linked libraries are linked with executables at the time there are build (when linking), so the functionality of the library becomes a part of the executable file. But, the dynamically linked libraries get loaded to the executable at run time. Most of the dlls get loaded when the new process for the executable is build by the operating system. Also, at run time, The process can load any necessary library by calling the win32 API call, LoadLibrary().

There are many advantages of using libraries. One obvious advantage is you can reuse the functionality you packaged to the library module later. Also, you can use libraries created by others to use the functionality implemented by others easily. The functionality implemented in dlls can be used by other programming languages as well.

Also, if you are using same dll in multiple applications, the applications do not need to contain the functionality in their executable files. Only one copy of the dll is enough for all of them so it saves the disk space. Also, if 2 or more applications which use the same dll are running simultaneously, then loading only one image of the dll to the memory is enough. The image of the dll loaded to the memory is mapped to the virtual address spaces of all the process requiring it by the operating system. So it saves memory too. For an example, any application running on win32 API (you may have not even seen a Windows application which is not running on win32 API) need to use the dlls such as kernal32.dll, user32.dll and gdi32.dll to make API calls because the win32 API is implemented in those dlls. So, loading just one image of each dll is enough for all the applications using these dlls. It saves lot of memory.

Again, with dlls, it is possible to modify, improve, bug fix, the dll without changing its interface, so any application which uses the dll will not be functionally affected.

The tutorials in this section will show you how to create dlls and libs using Visual Studio.

 

Creating Statically Linked Library Modules (LIB s)
Creating Dynamically Linked Library Modules (DLL s)