Microsoft Visual Studio 2019 Community Version – Creating and Using a C Based Dynamic Link Library © March 22, 2024, by James Pate Williams, Jr.

Create a solution using the DLL C++ DLL template. Rename pch.cpp to pch.c and dllmain.cpp to dllmain.c. Add a header file for the DLL containing the following macro:

#define DLL_Export __declspec(dllexport)

Mark all the exportable functions in the DLL header file with the DLL_Export macro. Suppose the DLL is named CSortingDLL. Next create a console C++ project in the DLL solution to use the DLL. Open the Properties page of the console app. If you want to use the ASCII character set, select the Advanced Configuration Properties, and set the Character Set to Not Set. Now open the C/C++ General Property and under Additional Include Directories add ..\CSortingDLL\;. Do not include the previous period mark. Next open the Linker General Property page. Set Additional Library Directories to ..\CSortingDLL\$(IntDir);. The penultimate step is to set the Linker Input Additional Dependencies to CSortingDLL.lib;. The final step for the app is to add a reference to CSortingDLL.  Now you have a functioning DLL and an app using the DLL. If you have any questions, please contact me via email at jamespate@mac.com.  Also, Microsoft has a DLL walkthrough complete with source code. I will add my CSortingDLL header source code as a PDF document.