1. What Is Cross-Linking?
In LabVIEW, cross-linking occurs because there is a difference between VIs in memory and VIs on disk. LabVIEW items in memory are unique by name, but multiple VIs with the same name can exist on disk. As a result, when you try to load a VI from disk, LabVIEW first checks to see if a VI already in memory has the same name, and, depending on the result, prompts you to use the VI in memory or discard it and use the VI from disk.
However, for subVIs, LabVIEW does not prompt you to declare whether to use the VI in memory or the VI of the same name on disk. Instead, LabVIEW links to the VIs already in memory and presents you with a warning dialog saying that LabVIEW loaded VIs from unexpected locations.
While cross-linking is easy to define, it is often difficult to prevent. A common practice among LabVIEW users is creating backups for any working directories as a means of providing a recovery point if work is lost. As a result, there are often many copies or branches of any given VI on a development machine. Cross-linking causes many problems and challenges for LabVIEW users, including the following:
Unexpected system behavior introduced by calling a subVI that has different functionality than the intended subVI
Accidental modifications that result from making edits to a VI other than the one you meant to edit or saving VIs into newer versions of LabVIEW unintentionally
Reduced productivity caused by wasting time finding and repairing cross-linking, as well as restoring VIs
Refer to the following LabVIEW Help topics for more information on cross-linking.
2. Tools in LabVIEW for Predicting, Preventing, and Repairing Cross-Linking
LabVIEW 8.5 introduces a plethora of new tools designed to help LabVIEW users not only identify and prevent possible cross-linking situations but also repair cross-linking where it has already occurred. The majority of these new features are integrated into the LabVIEW Project, whose original incarnation in LabVIEW 8 was intended to improve target management (for example, help developers manage VIs on the host and embedded systems simultaneously).
A LabVIEW Project now can contain items that conflict with other items in the same LabVIEW Project. A conflict is a potential cross-link that occurs when LabVIEW tries to load a VI that has the same qualified name as an item already in the LabVIEW Project. When LabVIEW identifies a conflict (in other words, a potential cross-linking situation), it displays the word [Conflict] after the name of the VI in the LabVIEW Project (see Figure 1). A yellow warning triangle also appears on any conflicting items in the LabVIEW Project.
Figure 1. A LabVIEW Project with a Conflict.
To prevent cross-linking, you can use the following new features in LabVIEW 8.5 to eliminate conflicts.
- Improved Show Full Paths option
- New Files page
- New Resolve Project Conflicts dialog box
- Ability to easily replace a VI in a LabVIEW Project
- New Find Callers and Find SubVIs dialog boxes
To explain how you can leverage these new tools with the LabVIEW Project to resolve conflicts (and thereby prevent cross-linking), this tutorial steps through each new feature with a simple example to illustrate each point.
In this situation, you can examine the files referenced by the LabVIEW Project to locate the source of the conflict. To help prevent conflicts, LabVIEW automatically tracks the hierarchy of every item you include in the LabVIEW Project. When you open a VI from a LabVIEW Project, LabVIEW adds all members of the VI hierarchy that are not already in the LabVIEW Project to Dependencies. LabVIEW organizes Dependencies in three folders – vi.lib, user.lib, and Items in Memory. When you open a VI that is not currently in the LabVIEW Project, LabVIEW adds the VI to Items in Memory. These items remain in the LabVIEW Project as long as the VI they reference is in memory. Dependencies updates when you add, remove, or save an item in the LabVIEW Project (Figure 2).
Figure 2. A Second VI Is Referenced as a Dependency, Causing the Conflict.
If a dependent item conflicts with another LabVIEW Project item, removing the items that reference it removes the item from Dependencies. However, before removing an item with a conflict, you must first determine why this conflict exists.
4. View Full Paths
The simplest way to determine why a conflict exists (which could potentially lead to cross-linking) is to view the full path to any item in the LabVIEW Project with the [Conflict] message next to it. You can right-click the project root and select View»Full Paths from the shortcut menu to display the Paths column and view the file paths that correspond to LabVIEW Project items (Figure 3).
Figure 3. The LabVIEW Project with Full Paths for Items Displayed.
While viewing full paths is not technically new (you could turn on full paths in LabVIEW 8 and 8.20), it was not previously a separate column in the LabVIEW Project. With a cleaner, easier to understand layout, the Full Paths option helps you see the exact location on disk where a conflicting item is located. To remove the conflict, you must rename or remove all but one item with the same qualified name from the LabVIEW Project.
5. Files Page in the Project
You can also view the locations of the files on the new Files page. Through the Items page, which displays the contents of the LabVIEW Project, you interact with familiar components of the LabVIEW Project that existed in LabVIEW 8 and 8.20 such as My Computer, Build Specifications, and Dependencies (see Figure 1). The new Files page displays the LabVIEW Project items that have a corresponding file on disk (see Figure 4).
Figure 4. The Files Page Displays the Locations of Items on Disk.
With the Files page, you can visually confirm that unwanted VIs and other files located in obsolete directories are not accidentally included in a particular LabVIEW Project. You can also perform disk operations such as rename, reorganize, and remove. For example, if you rename a file on the Files page, LabVIEW renames that file on disk. You can move files on disk using the Files page without adversely affecting VI linking. When you move a VI through the Files page, LabVIEW automatically updates all callers within that LabVIEW Project with the latest file location information for that VI.
You can switch from one page to the other by right-clicking a folder or item under a target and selecting Show in Items View or Show in Files View from the shortcut menu. The Show in Items View and Show in Files View shortcut menu items appear only if the item exists in the other view.
6. Resolve Conflicts Dialog
The most automated method for resolving conflicts in a LabVIEW Project is to use the Resolve Conflicts button in the LabVIEW Project toolbar to display the Resolve Project Conflicts dialog box. You can right-click a conflicting item and select Resolve Conflicts from the shortcut menu as well as use the Resolve Project Conflicts dialog box to resolve conflicts by redirecting the conflicting items to call items from the correct path (Figure 5).
Figure 5. The Resolve Project Conflicts Dialog Box Provides an Automated Means to
Remove Conflicts from the LabVIEW Project.
This dialog box displays all LabVIEW Project conflicts by qualified name. Within the dialog, you can compare two conflicting VIs with the same name (the existing graphical differencing feature is invoked). You can also view details for each item you select, such as the item path, qualified name, creation date, and modification date. This information is useful in determining which item is the correct one for an application to use. As you resolve each conflict in the dialog, the list automatically updates to reflect this.
7. Replace with…
If you detect that one or more VIs incorrectly refer to the wrong subVI and you do not want to use the Resolve Project Conflict dialog to fix the issue, you have other options for eliminating the conflict. You can redirect all callers to reference a subVI with a different path by right-clicking a conflicting VI in the LabVIEW Project and selecting Replace with from the shortcut menu to choose the correct subVI on disk (Figure 6). LabVIEW automatically updates all items that reference the incorrect path with the replacement path.
Figure 6. Right-click on a File and Choose Replace with to Choose a New File.
LabVIEW 8.5 added major new features to the LabVIEW Project. These features address cross-linking, a long-standing problem for many developers using LabVIEW (especially for large applications). With these new features, you have a number of ways in which you can predict, avoid and repair cross-linking situations, resulting in increased productivity and reduced debugging time.
9. Learn More About LabVIEW
To learn more about features and changes in LabVIEW, visit What's New in LabVIEW.
Launch LabVIEW online to use the latest features.