You can use the Application Builder to build a shared library. You can configure settings for specified VIs to add passwords, remove block diagrams, or apply other settings. You also can select different destination directories for VIs in a source distribution without breaking the links between VIs and subVIs. Before you create a build specification or start the build process, review the Building Applications Checklist.
|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. Refer to the NI Developer Zone for a step-by-step tutorial on creating a sample shared library.
|Note (Windows) Building a shared library is the same as creating a DLL.|
- 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.
Configuring the Build Specification
- Expand My Computer. Right-click Build Specifications and select New»Shared Library from the shortcut menu to display the Shared Library Properties dialog box. If you previously hid Build Specifications in the Project Explorer window, you must display the item again to access it.
- Complete the following items on the 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. Shared libraries must have one of the following extensions:
- (Windows) .dll
- (Mac OS X) .framework
- (Linux) You can use .so or you can begin with lib and end with .so, optionally followed by the version number. This allows other applications to use the library.
- Enter the location for the shared library in the Destination directory text box. You can use the Browse button to navigate to and select a location.
- 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. You also can select multiple files in the Project Files tree to add several files at one time to the Exported VIs or Always Included listbox.
|Note You cannot include a polymorphic VI or a LabVIEW class in the Exported VIs or Always Included listboxes. Use an instance of the polymorphic VI instead.|
- Click the Add Item arrow button next to the Exported VIs listbox to move the selected VI to the Exported VIs listbox. The Define Prototype dialog box appears. Use this dialog box to define the parameters of the exported VI.
Define the parameters of the exported VI in the Define VI Prototype dialog box then click the OK button to return to the Shared Library Properties dialog box.
- 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 shared library that uses shared variables, do not include the .lvlib file in the shared library. Change the Destination of the .lvlib file to a destination outside the shared library.|
Customizing Advanced Options
- From the Advanced page, configure advanced settings for the shared library.
- From the Additional Exclusions page, configure settings to disconnect type definitions, remove unused polymorphic VI instances, and remove unused members of project libraries to reduce the size of the shared library.
- From the Version Information page, configure the version number and other shared library information.
- 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 Pre/Post Build Actions page, specify VIs for LabVIEW to execute before or after the build.
Previewing and Building the Application
- From the Preview page, click the Generate Preview button to review the generated files for the shared library.
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.
Creating or updating the build specification does not build the shared library. You must complete the next step to build the 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 Destinations page of the build specification.
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 can duplicate build specifications. Right-click the build specification item you want to duplicate and select Duplicate from the shortcut menu to create a copy of the build specification item.
If you rebuild a given specification, LabVIEW overwrites the existing files from the previous build that are part of the current build.
You also can build a shared library programmatically from a build specification.
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.
Building and Distributing Applications Home