You are viewing the article How to Create a DLL file at Thptlaihoa.edu.vn you can quickly access the necessary information in the table of contents of the article below.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 3,690 times.
DLL is a dynamic link library file written and controlled by the C++ language. DLL files make it simple to share, store, and save code. This wikiHow teaches you how to create DLL files using Visual Studio on Windows or Visual Studio for Mac. During the installation process, do not forget to check the box “Desktop Development with C++”. If the computer already has Visual Studio but this box is not checked, you can relaunch the installer to check the option.
Steps
![Image titled 11227960 1](https://www.wikihow.com/images_en/thumb/c/c6/11227960-1.jpg/v4-728px-11227960-1.jpg)
- You can get Visual Studio for Windows here: https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio?view=vs-2019
- Here is the link to download Visual Studio for Mac: https://docs.microsoft.com/en-us/visualstudio/mac/installation?view=vsmac-2019
- This wikiHow will use code provided by Microsoft to explain how to build DLL files.
![Image titled 11227960 2](https://www.wikihow.com/images_en/thumb/8/89/11227960-2.jpg/v4-728px-11227960-2.jpg)
![Image titled 11227960 3](https://www.wikihow.com/images_en/thumb/1/11/11227960-3.jpg/v4-728px-11227960-3.jpg)
![Image titled 11227960 4](https://www.wikihow.com/images_en/thumb/e/e0/11227960-4.jpg/v4-728px-11227960-4.jpg)
- Click Language to open the drop-down menu and select C++ .
![Image titled 11227960 5](https://www.wikihow.com/images_en/thumb/5/54/11227960-5.jpg/v4-728px-11227960-5.jpg)
![Image titled 11227960 6](https://www.wikihow.com/images_en/thumb/7/78/11227960-6.jpg/v4-728px-11227960-6.jpg)
![Image titled 11227960 7](https://www.wikihow.com/images_en/thumb/a/a0/11227960-7.jpg/v4-728px-11227960-7.jpg)
![Image titled 11227960 8](https://www.wikihow.com/images_en/thumb/e/eb/11227960-8.jpg/v4-728px-11227960-8.jpg)
![Image titled 11227960 9](https://www.wikihow.com/images_en/thumb/8/8a/11227960-9.jpg/v4-728px-11227960-9.jpg)
![Image titled 11227960 10](https://www.wikihow.com/images_en/thumb/d/de/11227960-10.jpg/v4-728px-11227960-10.jpg)
- Select Visual C++ from the menu on the left side of the dialog box.
- Select Header file (.h) in the middle of the dialog box.
- Enter “MathLibrary.h” in the name field below the menus.
- Click Add to create a blank header file.
![Image titled 11227960 11](https://www.wikihow.com/images_en/thumb/7/7d/11227960-11.jpg/v4-728px-11227960-11.jpg)
- Here is sample code from the Microsoft help website.
// MathLibrary.h - Contains declarations of math functions#pragma once#ifdef MATHLIBRARY_EXPORTS#define MATHLIBRARY_API __declspec(dllexport)#else#define MATHLIBRARY_API __declspec(dllimport)#endif// The Fibonacci recurrence relation describes a sequence F// where F( n) is { n = 0, a// { n = 1, b// { n > 1, F(n-2) + F(n-1)// for some initial integral values a and b.// If the sequence is initialized F(0) = 1, F(1) = 1,// then this relation produces the well-known Fibonacci// sequence: 1, 1, 2, 3, 5, 8, 13, 21, 34, ...// Initialize a Fibonacci relation sequence// Such that F(0) = a, F(1) = b.// This function must be called before any other function.extern"C"MATHLIBRARY_APIvoidfibonacci_init(constunsignedlonglonga,constunsignedlonglongb);// Produce the next value in the sequence.// Returns true on success and updates current value and index;// false on overflow, leaves current value and index unchanged.extern"C"MATHLIBRARY_APIbopfibonacci_next();// Get the current value in the sequence.extern"C"MATHLIBRARY_APIunsignedlonglongfibonacci_current();// Get the position of the current value in the sequence.extern"C"MATHLIBRARY_APIunsignedfibonacci_index();
![Image titled 11227960 12](https://www.wikihow.com/images_en/thumb/1/10/11227960-12.jpg/v4-728px-11227960-12.jpg)
- Select “ Visual C++ ” from the menu on the left side of the dialog box.
- Select “ C++ File (.cpp) ” in the middle of the dialog box.
- Enter “MathLibrary.cpp” in the name field located below the menus.
- Click Add to create a blank file.
![Image titled 11227960 13](https://www.wikihow.com/images_en/thumb/7/7c/11227960-13.jpg/v4-728px-11227960-13.jpg)
- Here is sample code from the Microsoft help website.
// MathLibrary.cpp : Defines the exported functions for the DLL.#include"stdafx.h" // use pch.h in Visual Studio 2019#include<utility>#include<limits.h>#include"MathLibrary.h"// DLL internal state variables:staticunsignedlonglongprevious_;// Previous value, if anystaticunsignedlonglongcurrent_;// Current sequence valuestaticunsignedindex_;// Current seq. position// Initialize a Fibonacci relation sequence// such that F(0) = a, F(1) = b.// This function must be called before any other function.voidfibonacci_init(constunsignedlonglonga,constunsignedlonglongb){index_=0;current_=a;previous_=b;// see special case when initialized}// Produce the next value in the sequence.// Returns true on success, false on overflow.bopfibonacci_next(){// check to see if we'd overflow result or positionif((ULLONG_MAX-previous_<current_)||(UINT_MAX==index_)){returnfalse;}// Special case when index == 0, just return b valueif(index_>0){// otherwise, calculate next sequence valueprevious_+=current_;}std::swap(current_,previous_);++index_;returntrue;}// Get the current value in the sequence.unsignedlonglongfibonacci_current(){returncurrent_;}// Get the current index position in the sequence.unsignedfibonacci_index(){returnindex_;}
![Image titled 11227960 14](https://www.wikihow.com/images_en/thumb/8/8f/11227960-14.jpg/v4-728px-11227960-14.jpg)
![Image titled 11227960 15](https://www.wikihow.com/images_en/thumb/e/e0/11227960-15.jpg/v4-728px-11227960-15.jpg)
- If the DLL file is created successfully, you will see the above content. If an error occurs, a message will appear for you to fix. [1] XResearch Source
1>-----Buildstarted:Project:MathLibrary,Configuration:DebugWin32------1>MathLibrary.cpp1>dllmain.cpp1>GeneratingCode...1>CreatinglibraryC:UsersusernameSourceReposMathLibraryDebugMathLibrary.libandobjectC:UsersusernameSourceReposMathLibraryDebugMathLibrary.exp1>MathLibrary.vcxproj->C:UsersusernameSourceReposMathLibraryDebugMathLibrary.dll1>MathLibrary.vcxproj->C:UsersusernameSourceReposMathLibraryDebugMathLibrary.pdb(PartialPDB)==========Build:1succeeded,0failed,0up-to-date,0skipped==========
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 3,690 times.
DLL is a dynamic link library file written and controlled by the C++ language. DLL files make it simple to share, store, and save code. This wikiHow teaches you how to create DLL files using Visual Studio on Windows or Visual Studio for Mac. During the installation process, do not forget to check the box “Desktop Development with C++”. If the computer already has Visual Studio but this box is not checked, you can relaunch the installer to check the option.
Thank you for reading this post How to Create a DLL file at Thptlaihoa.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: