Example: Importing Functions from a Shared Library File
Complete the following steps to create and update a library of VIs based on the functions in a regular expression DLL using the Import Shared Library wizard. Refer to Importing Functions from a Shared Library File to create or update wrapper VIs for functions in any shared library file.
Select Tools�Import�Shared Library to launch the Import Shared Library wizard. The Specify Create or Update Mode page appears.
Click the Browse button next to the Shared Library File text box to navigate to and select labview\examples\dll\ImportSharedLibraryExample\ImportSharedLibraryExample.dll. After you select this file, LabVIEW designates labview\examples\dll\ImportSharedLibraryExample\ImportSharedLibraryExample.h as the default header file.
Note��ImportSharedLibraryExample.dll is not supported on macOS.
If a checkmark appears in the Shared library file is not on the local machine checkbox, remove it.
Click the Next button to display the Select Functions to Convert page. A dialog box appears to notify you that LabVIEW is parsing the specified header file.
Select the functions for which you want to create wrapper VIs by placing a checkmark in the checkbox next to each function. The two functions that appear contain checkmarks by default. LabVIEW creates VIs for each of the functions you select.
By default, ImportSharedLibraryExample appears in the Project Library Name (.lvlib) field. LabVIEW automatically includes all generated VIs within this project library file and gives it a .lvlib file extension. Also by default, labview\user.lib\ImportSharedLibraryExample appears in the Project Library Path field, and the Copy the shared library file to the destination directory checkbox contains a checkmark.
Select Function Returns Error Code/Status from the Error Handling Mode pull-down menu. If an error occurs, use the error status description to form the error cluster information in LabVIEW.
Review the configuration for the VIs and controls you want to create. Select a VI or a control on the left and then use the fields on the Settings and Name and Description tabs to review and edit specific information. Make the following changes to the default configuration settings:
DWTest_Change_Info()
Change the Default string to initialize the pointer text box for name to Old.
DWTest_Copy()
Change Input/Output for outputEnum1 to Output.
Change Input/Output for outputEnum2 to Output.
Change Input/Output for outputRunTimeSizeArray to Output.
Change Input/Output for outputBool to Output.
Change Input/Output for outputString to Output.
Tip��You can change VI and control names to be more descriptive or to improve readability. Similarly, control names in LabVIEW can include spaces to improve readability.
Click the Next button to display the Generation Summary page, and review the Generation Summary to determine if you are ready to generate VIs. If you want to make any changes, click the Back button.
Click the Next button to create wrapper VIs for the functions you selected in the specified shared library. The Generation Progress page shows the progress of the wizard as it generates the wrapper VIs. When the generation completes, the Finish page appears.
Place checkmarks in the Open the generated library and View the report checkboxes, and click the Finish button to close the wizard, open the project library file, and view the report in the default browser.
Review the report. The report indicates that no errors or warnings occurred.
Review the project library file and the generated VIs within it. After you initially generate the VIs, you can make changes to the VIs individually within the block diagram or front panel of each VI. Then you can re-run the wizard to update the VIs within the library.
Close the ImportSharedLibraryExample.lvlib project library file.
Update the Generated Project Library VIs with Custom Controls
The generated library is complete and usable as is. However, you might want to make changes to several VIs within the library. To do this, you can re-launch the wizard and select the Update VIs for a shared library option on the Specify Create or Update Mode page. With this option, you can update and overwrite specific VIs that you generated previously. Complete the following steps to update a subset of the VIs within ImportSharedLibraryExample.lvlib with custom controls:
Select Tools�Import�Shared Library to launch the Import Shared Library wizard. The Specify Create or Update Mode page appears.
Select Update VIs for a shared library and select ImportSharedLibraryExample.lvlib from the list of projects.
Click the Next button to display the Select Shared Library and Header File page of the wizard. The Shared Library File text box contains the path labview\examples\dll\ImportSharedLibraryExample\ImportSharedLibraryExample.dll, and the Header (.h) File text box contains labview\examples\dll\ImportSharedLibraryExample\ImportSharedLibraryExample.h as the default header file.
Note��ImportSharedLibraryExample.dll is not supported on macOS.
Click the Next button to display the Configure Include Paths and Preprocessor Definitions page. You do not need to add any additional include paths or preprocessor definitions for this DLL.
Click the Next button to display the Select Functions to Convert page. A dialog box appears to notify you that LabVIEW is parsing the specified header file.
Select the functions you want to convert by placing a checkmark in the checkbox next to each function. The two functions that appear contain checkmarks by default. Click the Uncheck All button to remove the checkmarks.
Place a checkmark in the checkbox next to DWTest_Copy() to select it as the function to update.
Click the Next button to display the Configure Project Library Settings page. You do not need to change any of the settings on this page.
Click the Next button to display the Select Error Handling Mode page. LabVIEW prompts you to confirm whether you want to overwrite the specified files. Click the OK button.
On the Select Error Handling Mode page, select Function Returns Error Code/Status from the Error Handling Mode pull-down menu.
Click the Next button to display the Configure VIs and Controls page.
Make the following changes to the default configuration settings:
DWTest_Copy()
Change the Control Type of outputStruct to Custom Control.
Click the Browse button next to the Path to Custom Control field to navigate to labview\examples\dll\ImportSharedLibraryExample\CustomDefinedControl.ctl as the custom control.
Click the Next button to display the Generation Summary page.
Click the Next button to update the VIs.
On the Finish page, select the Open the generated library option and click the Finish button to close the wizard and open the project library file.
Close the ImportSharedLibraryExample.lvlib project library file.