Walkthrough: Create and use your own Dynamic Link Library (C++) using Visual Studio 2019

Prerequisites

  • Visual Studio 2019
  • Desktop development with C++ workload

Create the DLL project

image

image

image

Add .h file

image

image

Copy code from Microsoft docs.

image

Add .cpp file

image

Copy code from Microsoft docs.

image

Build Solution

image

Succeeded !!

image

 

Create a client app that uses the DLL

image

image

image

Right-click > Properties

image

Configuration Properties > C/C++ > General > Additional Include Directories edits the directory for MathLibrary.h

(path for MathLibrary.h)

image

image

image

image

image

Configuration Properties > Linker > Input > Additional Dependencies key in MathLibrary.lib

image

image

image

Configuration Properties > Linker > General > Additional Library Directories edits the directory for MathLibrary.lib

(path for MathLibrary.lib)

image

image

image

image

image

Modify MathClient.cpp: copy code from Microsoft docs.

image

Build -> Succeeded !!

image

Copy the .dll file to the same folder of the .exe file, then execute the MathClient.exe!

image

image

 

Reference:

Microsoft docs: Walkthrough: Create and use your own Dynamic Link Library (C++)

vince 學習筆記: C/C++ 製作 DLL 教學

 

arrow
arrow
    文章標籤
    Visual Studio 2019 C++ DLL
    全站熱搜

    yoruru 發表在 痞客邦 留言(0) 人氣()