The example will guide you through using DLLs built using Visual C++ in the C compiler of LabWindows/CVI
While calling C based DLLs in LabWindows/CVI is a breeze, calling DLLs built in other languages such as Visual C++ can be somewhat more involved. This example will demonstrate how to properly set up a project in Microsoft Visual Studio to build a visual C++ DLL. Then, we will call functions from that DLL in LabWindows/CVI.
Microsoft Visual Studio 2010 (or compatible)
LabWindows/CVI 2013 (or compatible)
Steps to Implement or Execute Code
Open The DynamicLibrary.sln solution from the Visual Studio VCPP project folder
Analyze solution and project. Note the MathFuncsDll.h file
Notice that the function declarations in the .h file also include the following:
extern "C" __declspec(dllexport) double __cdecl DGAdd(double a, double b);
extern "C" __declspec(dllexport) double __cdecl Subtract(double a, double b);
extern "C" __declspec(dllexport) double __cdecl Multiply(double a, double b);
The "extern "C" __declspec(dllexport)" and "__cdecl" declarations are necessary to be able to use this DLL in code that will be compiled with a C based compiler.
If no changes are made skip to step 5. If you do make changes, mode the modified .h, .lib, .pdb, and .dll files over to the CVI project folder of interest.
Open the "dll test.cws" workspace from the CVI project folder.
Open the Command-line Application.c file and analyze
Notice that the only files included in the project are the .h and .lib files. Note: DO NOT INCLUDE .DLL FILE
Run program and notice use of functions from Visual C++ dll.