Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Apr 12, 2007

Building DLLs in LabVIEW 6.x or later

31 ratings | 3.42 out of 5
Print

Overview

You can use the LabVIEW 6.x Application Builder to create shared libraries (DLLs) from VIs, so you can call the VIs in the shared library using text-based programming languages, such as LabWindows/CVI, Microsoft Visual C++, and Microsoft Visual Basic.

Note: The LabVIEW Professional Development System includes the Application Builder. If you use the LabVIEW Base Package or Full Development System, you can purchase the Application Builder separately, using the related links below.

Refer to the LabVIEW Help, available by selecting Help»Contents and Index, for more information about building shared libraries, including descriptions of fields in the dialog boxes shown below.

Creating a VI

Complete the following steps to create a VI that converts a temperature from degrees Fahrenheit to degrees Celsius, which you easily can call from text-based programming languages.

  1. Use the following equation to create a VI to perform the conversion.
    Deg C = (Deg F - 32) / 1.8
    The block diagram and front panel should appears as follows.


  2. Assign the control and indicator to terminals in the connector pane. This step is necessary to create the DLL. Refer to the LabVIEW Help, available by selecting Help»Contents and Index, for more information about assigning controls and indicators to terminals.

  3. Save and close the VI, because the VI cannot be in memory when you create the DLL.

Creating a DLL in LabVIEW


Complete the following steps to create a DLL from the VI you built.
  1. Open a new VI and select Tools»Build Application or Shared Library (DLL).

  2. Select Shared Library (DLL) in the Build Target field and specify a name for the DLL and destination and support directories.


    [+] Enlarge Image
  3. Click the Source Files tab, click the Add Exported VI button, and double-click your main VI. The following dialog box appears.

  4. Select the input parameter (DegF) and click the plus (+) button to add the input to the DLL. Also, select whether you want to pass the parameter as a value or a pointer to value. In this case, select Value in the Pass By field. The function prototype changes at the bottom of the dialog box.


    [+] Enlarge Image
  5. Repeat the previous step for the other parameters, such as the Deg C output. This output is passed as a pointer by default.


    [+] Enlarge Image
  6. You also can select any of your output parameters as the return value of your function. The following function returns the DegC 64 bit floating-point number instead of a void. Therefore, you have two options for generating outputs from your function. You can add it as an output parameter or return it. The following function does both.


    [+] Enlarge Image
  7. Click the OK button in the Define VI Prototype dialog box.

  8. Click the Build button in the Build Application or Shared Library (DLL) dialog box to create the DLL. LabVIEW creates the DLL in the destination directory along with a header and library file. In this example, the destination directory is c:\temp\app.


    [+] Enlarge Image

Calling a LabVIEW DLL


Refer to the following links for examples of how you can call this DLL from Microsoft Visual Basic, Microsoft Visual C++., and LabWindows/CVI.
See Also:
Calling a DLL from Microsoft Visual Basic That Was Generated By LabVIEW 6i
Calling a DLL from Microsoft Visual C++ that Was Generated by LabVIEW 6i
Calling a DLL from LabWindows/CVI That Was Generated by LabVIEW 6i

Related Links:
LabVIEW Application Builder for Windows
LabVIEW Application Builder for Mac OS
LabVIEW Application Builder for Sun Solaris 2
LabVIEW Application Builder for HP-UX
LabVIEW Application Builder for Linux
31 ratings | 3.42 out of 5
Print

Reader Comments | Submit a comment »

Does not show how to pass arrays or other data types from a LabView VI to a dll.
- Apr 2, 2008

need to know how to pass each data type used in LabView DLL within LabView.
This example is not helpful because it does not show all of the available data type that can be passed from LV dll to LV call dll function. A more detailed document is needed at this point to clearly define how to LabView dll data type can be passed in LabView and how the header file could be more useful in explaining parameter links.
- Dec 16, 2003

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).