Deploying Network Shared Variables from a Compiled Executable

Updated Jul 27, 2023

Environment

Software

  • LabVIEW Real-Time Module
  • LabVIEW Datalogging and Supervisory Control Module
  • LabVIEW

I have created an executable that contains network shared variables, but when I try to run the program, it appears that the variables do not deploy automatically. How do I deploy the shared variables?

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):
  1. In Build Specifications, select Shared Variable Deployment.
  2. To deploy the libraries at application execution time, check the box titled Deploy shared variable libraries at application execution.
  3. To undeploy libraries when the application finishes, check the box titled Undeploy shared variable libraries at application exit.
sharedvar deploy.PNG

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:
  1. 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
  2. Using the hand tool, click Method and select Library»Deploy Library
  3. 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:
  1. 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
  2. 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:
  1. In LabVIEW, go to Tools»Shared Variable»Variable Manager
  2. Add an RT system to monitor by right-clicking RT Systems
  3. 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:
  1. 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
  2. Using the hand tool, click Method and select Library»Deploy Library
  3. 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
  1. 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)
  2. Transfer the executable onto the deployment computer that is connected to the RT target and does not have LabVIEW Development System installed 
  3. Transfer a copy of the shared variable to the same directory as the executable.
  4. Run the executable on the PC with connectivity to the RT target.
  5. Reboot the target from NI MAX
  6. 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.