Building a Shared Library (DLL)

Use the Application Builder to create shared libraries (DLLs) for VIs. Use shared libraries if you want to call the VIs in the shared library using text-based programming languages. Shared libraries are useful when you want to share the functionality of the VIs you build with text-based programming language developers. You also can use the Call Library Function Node to call a DLL.

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.

Complete the following steps to build a shared library in LabVIEW.

  1. Close any VIs you want to use to build the shared library.
  2. Select Tools»Build Application or Shared Library (DLL). The Build Application or Shared Library (DLL) dialog box appears.
  3. Complete the following items on the Target tab of the Build Application or Shared Library (DLL) dialog box.
    1. Select Shared Library (DLL) from the Build target pull-down menu.
    2. Enter a name for the shared library in the Target file name field.
    3. Complete any optional items on the Target tab.
  4. Complete the following items on the Source Files tab.
    1. Click the Add Exported VI button and select a VI to export as a function in the shared library. The Define VI Prototype dialog box appears.

      Note  You cannot use a polymorphic VI to create DLLs because each instance subVI of a polymorphic VI has the same connector pane pattern but different data types for inputs and outputs. Use an instance of the polymorphic VI to create the DLL.

    2. Click the Add (+) button to select the controls and indicators you want to include as parameters.

      To include the waveform data type as a parameter, select any waveform data type inputs and outputs from Param Type as you would for any other parameter you want to add. When you include a waveform data type as a parameter, the Function Prototype text box includes the entry (HWAVE parameter name) where parameter name is the name of the waveform input or output. An array of waveforms appears as (HWAVES parameter name).

      Note  When you call a shared library that includes a waveform data type, you do not have to specify a numeric value from the Data Type pull-down menu (the default is 8-byte double). However, you must specify a Dimension. If the Parameter is a single waveform, specify a Dimension of 0. If the Parameter is an array of waveforms, specify a Dimension of 1. LabVIEW does not support an array of waveforms of two or greater dimensions.

    3. Click OK to return to the Source Files tab.
    4. Highlight the VI name in the text box of the Source Files tab and click the Define VI Prototype button to return to the Define VI Prototype dialog box.

      Note  All DLLs built from LabVIEW, in addition to the functions you export, contain an exported function called LVDLLStatus, with the following prototype:

      MgErr LVDLLStatus(CStr errStr, int32 errStrLen, void *module);

      The calling program uses this routine to verify that the LabVIEW DLL loaded correctly. If an error occurs while loading the DLL, the function returns that error. Pass a string buffer to the errStr input to receive additional information about the error. Set the errStrLen input to the number of bytes in the string buffer passed as errStr. You can use the module parameter to retrieve the handle to the LabVIEW Run-Time Engine being used by the DLL. Typically, you can leave this parameter as NULL.
    5. Complete any optional items on the Source Files tab.
  5. Complete any optional items on the VI Settings, Application Settings, and Installer Settings tabs.
  6. (Optional) Click the Save or Save As button to save the settings you made for the current build in a build script.
  7. Click the Build button to build the shared library.
  8. You can find the resulting shared library in the directory specified in the Destination directory field on the Target tab.
  9. Click Done to close the Build Application or Shared Library (DLL) dialog box.
Note  Systems built using the Application Builder must include the LabVIEW Run-Time Engine.