Building a Shared Library (DLL)
You can use the Application Builder to build a shared library (DLL). Use shared libraries when you want to use text-based programming languages to call VIs. Before you create a build specification or start the build process, review the caveats and recommendations for LabVIEW build specifications.
 | 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 by visiting the National Instruments Web site. |
Complete the following steps to build a shared library.
- Open the LabVIEW project you want to use to build the shared library. You must have a project open and saved to configure a shared library build specification.
- Prepare the VIs you want to use to build the shared library. Save changes to any VIs in memory.
- Expand My Computer. Right-click Build Specifications and select New»Shared Library from the shortcut menu to display the Shared Library Properties dialog box.
- Complete the following items on the Shared Library Information page of the Shared Library Properties dialog box.
- Enter a name for the build specification in the Build specification name text box. This name appears under Build Specifications in the Project Explorer window. The name must be unique among other build specification names in the project.
- Enter a name for the shared library in the Target filename text box. Windows Shared libraries must have a .dll extension. Mac OS Shared libraries must have a .framework extension. Linux Shared libraries must have a .so extension.
- Enter the location for the shared library in the Shared Library destination directory text box. You can use the Browse button to navigate to and select a location.
- Enter the version information for the shared library in the Version Information section.
- Complete the following items on the Source Files page.
- From the Project Files tree, select the VI you want to define as an exported VI in the shared library. You must define at least one VI to export as a function in the shared library.
 | Note You cannot use a polymorphic VI as an exported VI in a shared library. Use an instance of the polymorphic VI instead. |
- Click the right arrow button next to the Exported VIs listbox to move the selected VI to the Exported VIs listbox. The Define VI Prototype dialog box appears.
- Click the Add (+) button to select the controls and indicators you want to include as parameters.
 | Note If you want to include a control or indicator as a parameter, you must use the connector pane of the VI to configure it as an input or output. |
- Click the OK button to return to the Source Files page.
 | Note Windows 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 function to verify that the LabVIEW DLL loaded correctly. If an error occurs while loading the DLL, the function returns the error. Pass a string buffer to the errStr parameter to receive additional information about the error. Set the errStrLen parameter 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. |
- From the Destinations page, configure destination settings and add destination directories to the shared library.
- From the Source File Settings page, edit destinations and properties for individual files and folders in the shared library.
 |
Note If you plan to distribute a DLL that uses shared variables, do not include the .lvlib file in the DLL. Change the Destination of the .lvlib file to a destination outside the DLL. |
- From the Advanced page, configure advanced settings for the shared library.
- From the Run-Time Languages page, set the language preferences for the shared library.
 | Note The LabVIEW Run-Time Engine must be installed on any computer on which users run the application or shared library. You can distribute the LabVIEW Run-Time Engine with the application or shared library. Windows You also can include the LabVIEW Run-Time Engine in an installer. |
- From the Preview page, click the Generate Preview button to review the generated files for the shared library.
 | Note Save changes to VIs in memory before you create or edit a build specification to ensure that the preview is accurate. |
- Click the OK button to update the build specification settings in the project and close the dialog box. The build specification name appears in the project under Build Specifications.
 | Note Creating or updating the build specification does not build the shared library. |
 | Note When you update the build specification settings, the settings become part of the project. However, you must save the project if you want to save the settings. |
- Right-click the shared library build specification name and select Build from the shortcut menu. You can find the resulting shared library in the directory specified in the Destination path on the page of the build specification.
 | Note You also can click the Build button in the Shared Library Properties dialog box to build the shared library and update the build specification. |
You also can build a shared library programmatically from a build specification.
Resources