Tools, FAQ, Tutorials:
"MathLibrary.h" - Header File of DLL Library
How to create a C++ Header File for DLL (Dynamic Link Library)?
✍: FYIcenter.com
Using a Dynamic Link Library (DLL) is a great way to reuse code.
Rather than re-implementing the same routines in every program that you
create, you write them one time and then reference them from apps that
require the functionality. By putting code in the DLL, you save space in
every app that references it, and you can update the DLL without recompiling
all of the apps that use it.
The first step to build a static library is to create a header (.h file) to represent the API of the library as shown in this tutorial:
1. Create the header file, MathLibrary.h, with a text editor:
// MathLibrary.h - Contains declaration of Function class #pragma once #ifdef MATHLIBRARY_EXPORTS #define MATHLIBRARY_API __declspec(dllexport) #else #define MATHLIBRARY_API __declspec(dllimport) #endif namespace MathLibrary { // This class is exported from the MathLibrary.dll class Functions { public: // Returns a + b static MATHLIBRARY_API double Add(double a, double b); // Returns a * b static MATHLIBRARY_API double Multiply(double a, double b); // Returns a + (a * b) static MATHLIBRARY_API double AddMultiply(double a, double b); }; }
2. Save the header file with your library source file. It is needed when you compile your library source code.
3. Send header file to anyone who wants to use your library. They need it to compile their application source code.
⇒ "MathLibrary.cpp" - Build DLL Library
⇐ "MyExecRefsLib.cpp" - Reference Static Library
2023-09-16, 2034🔥, 0💬
Popular Posts:
How To Set session.gc_divisor Properly in PHP? As you know that session.gc_divisor is the frequency ...
How to start Visual Studio Command Prompt? I have Visual Studio 2017 Community version with Visual C...
What is EPUB 2.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 2.0 Metadata "dc:publisher" ...
How to make application release build with Visual Studio 2017? If you want to make a final release b...
Where to find tutorials on JSON (JavaScript Object Notation) text string format? I want to know how ...