You are viewing the article How to Create a DLL file at Lassho.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
- 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.
- Click Language to open the drop-down menu and select C++ .
- 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.
- 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_API void fibonacci_init ( const unsigned long long a , const unsigned long long b ); // 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_API bop fibonacci_next (); // Get the current value in the sequence. extern "C" MATHLIBRARY_API unsigned long long fibonacci_current (); // Get the position of the current value in the sequence. extern "C" MATHLIBRARY_API unsigned fibonacci_index ();
- 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.
- 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: static unsigned long long previous_ ; // Previous value, if any static unsigned long long current_ ; // Current sequence value static unsigned index_ ; // 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. void fibonacci_init ( const unsigned long long a , const unsigned long long b ) { 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. bop fibonacci_next () { // check to see if we'd overflow result or position if (( ULLONG_MAX - previous_ < current_ ) || ( UINT_MAX == index_ )) { return false ; } // Special case when index == 0, just return b value if ( index_ > 0 ) { // otherwise, calculate next sequence value previous_ += current_ ; } std :: swap ( current_ , previous_ ); ++ index_ ; return true ; } // Get the current value in the sequence. unsigned long long fibonacci_current () { return current_ ; } // Get the current index position in the sequence. unsigned fibonacci_index () { return index_ ; }
- 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] X Research Source
1 >----- Build started : Project : MathLibrary , Configuration : Debug Win32 ------ 1 > MathLibrary . cpp 1 > dllmain . cpp 1 > Generating Code ... 1 > Creating library C : Users username Source Repos MathLibrary Debug MathLibrary . lib and object C : Users username Source Repos MathLibrary Debug MathLibrary . exp 1 > MathLibrary . vcxproj -> C : Users username Source Repos MathLibrary Debug MathLibrary . dll 1 > MathLibrary . vcxproj -> C : Users username Source Repos MathLibrary Debug MathLibrary . pdb ( Partial PDB ) ========== Build : 1 succeeded , 0 failed , 0 up - to - date , 0 skipped ==========
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 Lassho.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: