LabVIEW 2009 and Later
In LabVIEW 2009, functionality was introduced into the Application Builder to deploy shared variable libraries at run time. This option is available in the build specifications for the compiled executable and greatly simplifies and reduces the coding required to use shared variables with compiled executables. More information on
Shared Variable Deployment Page (Application Properties Dialog Box).
Note: The
Shared Variable Deployment tab is not available for Real-Time targets. For Real-Time targets, check the
Deploying Shared Variables to a Real-Time (RT) Target (All LabVIEW Versions) section.
To deploy shared variable libraries in executables built in LabVIEW 2009, follow these steps (and refer to the image below):
- In Build Specifications, select Shared Variable Deployment.
- To deploy the libraries at application execution time, check the box titled Deploy shared variable libraries at application execution.
- To undeploy libraries when the application finishes, check the box titled Undeploy shared variable libraries at application exit.
Note: The method described below for versions of LabVIEW prior to 2009 is still valid for LabVIEW 2009. Also, code written in previous versions that is upgraded and compiled into LabVIEW 2009 that uses the method described below need not be updated to use the method described above.
Before LabVIEW 2009
In order to use a network shared variable in a compiled executable in versions of LabVIEW prior to LabVIEW 2009, it is necessary to first deploy the shared variables before they are used in the program. When you create a new application (EXE), under
Build Specifications»Application (EXE)»Source Files, add your top-level VI as the
Startup VI and then add all libraries that contain network shared variables to the
Always Include (previously Support Files) list. Also, make sure to set the destination of the libraries to be
Support Directory in the
Source File Settings category.
Deploying Shared Variables From Windows
This can be done by utilizing the Deploy Library method of an Application Control. To find the Deploy Library method:
- Right-click the block diagram to bring up the programming palette and go to Programming»Application Control and place the Invoke Node on the block diagram
- Using the hand tool, click Method and select Library»Deploy Library
- Use the Lib Path input of the Deploy Library invoke node to point to the libraries containing your shared variables. If the libraries were included in the executable's Support Directory, as directed above, the libraries will be copied to the executable's data folder. Point the Lib Path input to these libraries.
If you are using LabVIEW Datalogging and Supervisory Control, you should use the Deploy Library function to deploy your shared variables. To find the Deploy Library VI:
- Right-click the block diagram to bring up the functions palette and go to DSC Module»Engine Control»Libraries & Processes (DSC Module»Engine Control before LabVIEW 8.5) and place the Deploy Library function on the block diagram
- Use the Path input to the Deploy Library function to point to the libraries containing your shared variables
Note: If the application you want to build uses VI Server properties and methods or DSC VIs to modify a library or shared variables within a library, place a checkmark in the
Enable Enhanced DSC Runtime Support checkbox on the
Advanced page of the Application Properties dialog box shown below. If you are planning to distribute this application to a machine without LabVIEW DSC installed, also be sure to check the
NI Enhanced DSC Deployment Support in the Additional Installers section of the installer properties.
Deploying Shared Variables to a Real-Time (RT)Target (All LabVIEW Versions)
If you are compiling an executable to be run on a Real-Time target, you may either manually deploy the shared variables from the Project Explorer window or programmatically deploy the shared variables from the PC to the Real-Time target using the Application invoke node.
In the Project Explorer, right-click each of the libraries you wish to deploy on your Real-Time target and select
Deploy All. The network shared variables that are deployed onto the Real-Time target will persist until you manually undeploy them. To undeploy network shared variables:
- In LabVIEW, go to Tools»Shared Variable»Variable Manager
- Add an RT system to monitor by right-clicking RT Systems
- Right-click the library you wish to undeploy and select Remove Library
You can also deploy the shared variables programmatically from the host PC to the Real-Time target using the Application invoke node:
- Right-click the block diagram to bring up the programming palette and go to Programming»Application Control and place the Invoke Node on the block diagram
- Using the hand tool, click Method and select Library»Deploy Library
- Use the Lib Path input of the Deploy Library invoke node to point to the libraries containing your shared variables. Also, specify the IP address of the Real-Time target using the Target IPAddress input.
If the PC connected to the Real-Time (RT) Target does not have LabVIEW Development System
- On a computer with LabVIEW Development system, build an executable of a VI that has an invoke node as you see above. (see the tutorial for building stand-alone applications from the related links sections below)
- Transfer the executable onto the deployment computer that is connected to the RT target and does not have LabVIEW Development System installed
- Transfer a copy of the shared variable to the same directory as the executable.
- Run the executable on the PC with connectivity to the RT target.
- Reboot the target from NI MAX
- Use Distributed System Manager to verify that your shared Variable is properly deployed.
Additional Information
- For all the cases discussed here, the system needs time to deploy the libraries, this is why you have to place a delay between the deployment and the first access to your variable(s).
- When running an executable on a computer without LabVIEW, you need to install the shared variable engine on that computer. You can include this in your installer by selecting "NI Variable Engine" in the "Additional Installers" category of your installer properties.