How To Create A Library In C++
With the help of DLL (Dynamic Link Library), we can make our project modular and reduce the development time. A DLL increase the performance of the project and promote the reusability of code. It also helps the developer to insert and remove the new functionality in the project without any hurdle.
Basically, DLL is a shared library that contains code and data that is used by more than one program at a time and like the executable file DLL cannot run directly. DLL (Dynamic-link library) is called by the application.
For example, in windows, the Kernel32.dll file handles memory management, input/output operations and interrupts.
The most important features of the DLL, it is loaded at run time when the application is requested for the DLL functionality and loading time is very low.
In this article, I will teach you how to create DLL in C++ and how to use this DLL by a C++ application.
Steps to create DLL in C++
Here I will describe how to create a DLL project in C++ using the visual studio.
- Open the visual studio and click on the menu bar to create a new project. See the below Image.
- After selecting the new project, a new dialog box will be open, here select the project type Win32 and give the name to the DLL project.
- On the Overview page of the Win32 Application Wizard dialog box, choose the Next button. After clicking the next button a new window will open. It is Application setting window here we will select the type of the application and click on the finish button to create the DLL project.
- After creating the DLL project you have to add the header files and source file as per your requirements. Here I am adding only one header file (Calculation.h).
- When you have created the header file then write the desired content as per the requirements. Here I am creating a library that performs some basic arithmetic operation like addition, subtraction, and multiplication.
//Calculation.h #pragma once #ifdef CALCULATIONDLL_EXPORTS #define CALCULATION_API __declspec(dllexport) #else #define CALCULATION_API __declspec(dllimport)

0 Response to "How To Create A Library In C++"
Post a Comment