Calling a DLL from LabWindows™/CVI™ That You Generated in LabVIEW 6i

Publish Date: May 19, 2014 | 0 Ratings | 0.00 out of 5 | Print

You can create DLLs in LabVIEW 6i that you can use in other programming environments. This document demonstrates how to use LabWindows/CVI to call a simple function in a DLL that you generated in LabVIEW 6i. Before you can complete the following steps, you must use LabVIEW 6i to create a VI and a corresponding DLL. Refer to the LabVIEW VI, Function & How-To Help for more information about how to build shared libraries (DLLs).

Note: This document applies to LabWindows/CVI 6.0 and LabVIEW 6i.

1. In LabWindows/CVI, create a new project by selecting File»New»Project (*.prj).

2. Add the header file to the project by selecting Edit»Add Files To Project»Include (*.h).

3. The header file is located in the directory that you designated as your destination directory when you created the DLL in LabVIEW. Click Add in the Add Files To Project dialog box to add the file to the project.

4. Select Library (*.lib) for Files of type and add the .lib file in the same manner that you added the header file in Step 3. Then click OK to exit the dialog box.

5. Create a new source file by selecting File»New»Source (*.c).

6. Write the following code, which calls the F_to_C function that you created in LabVIEW. Then add the source file to the project by selecting File»Add File To Project.

7. The source code must have a different name than the .h and .lib files. If it does not have a different name, LabWindows/CVI displays the following error message, prompting you to exclude the .lib file from the project. Do not exclude the .lib file. If you do so, the program will not link correctly.

8. Compile the source file by selecting Build»Compile File.

9. Build and run the executable by selecting Run»Debug FtoC_dbg.exe.

10. The header file that LabVIEW automatically created also includes the extcode.h file. If LabWindows/CVI cannot find this header file, it launches the following dialog box. Click Yes and navigate to the extcode.h file. This file is located in the Cintools files folder in the LabVIEW directory, generally Program Files»National Instruments»LabVIEW»Cintools»extcode.h.

11. LabWindows/CVI launches the following dialog box. Leave Add the directory to the list of include search paths enabled and click OK.

12. Notice that the 75 degrees Fahrenheit is converted to 23.9 degrees Celsius. Also, notice that the return value is equal to 23.9. This is because you set the return value equal to DegC when you built the DLL in LabVIEW. Therefore, when you build DLLs in LabVIEW, you have two options for generating outputs.

Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No