Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 36 ยท Deployment

Packed Libraries and Source Control

Organise LabVIEW code with projects, .lvlib libraries and packed project libraries (.lvlibp), manage VI Package Manager packages and use Git with binary VI files effectively.

A single VI is easy to manage. A product with hundreds of VIs, several developers and customers on different versions is not. This lesson covers the tools that keep LabVIEW code maintainable and shippable: the project, libraries, packed project libraries, packages and source control.

LabVIEW cannot run on this site, so each procedure is described in words and the two Python stand-ins illustrate the ideas (versioned dependencies and merge conflicts).

The project

A project (.lvproj) is an XML file that lists the files and targets of an application. It shows My Computer (or a real-time target) with your VIs, Dependencies (items found automatically) and Build Specifications. Good habits:

  • Make the project folder mirror a real folder on disk (Source, Tests, Docs). In the Project Explorer you can Add > Folder (Auto-populating) so new files appear without manual adds.
  • Keep VIs in the same folder as their callers or below it; avoid vi.lib-style dependencies on files outside the project tree.
  • Check Dependencies for items marked missing and fix them early.

Libraries (.lvlib)

A LabVIEW project library (.lvlib) groups VIs, controls and typedefs under one name. Benefits:

  • Namespace: a file inside the library is named MyLib.lvlib:Read.vi, so two libraries can each have a Read.vi without conflict.
  • Access scope: mark items Public or Private. Private VIs can only be called by VIs in the same library, so users of the library cannot depend on your internals.
  • Single unit to move: open the library to see all items and save them together.

Create one by right-clicking the project > New > Library; drag in files or create them from the library. Renaming happens inside the library so callers update.

Packed project libraries (.lvlibp)

A packed project library is a library compiled into a single file, optionally without block diagrams, that can be called like a library but cannot be edited. Create one with Build Specifications > New > Packed Library and choose the library. Reasons to use it:

  • Faster loading and fewer files to deploy.
  • Protect intellectual property by removing diagrams.
  • Freeze a tested version: other projects link to Utils.lvlibp and cannot change it accidentally.

Packed libraries have the name of the packed file as a namespace (Utils.lvlibp:Read.vi). A VI inside a packed library is loaded into the caller's application separately, with its own memory, so mixing .lvlib and .lvlibp versions of the same code in one project can cause confusing behaviour. Pick one form for each library per application.

Class and malleable VI notes

For object-oriented designs, LabVIEW classes (.lvclass) group data (a private cluster) with methods. They give you inheritance, dynamic dispatch and encapsulation, which are very handy for instrument abstraction layers (a Multimeter base class with Fluke and Keysight children) and in the unit testing discussion for swapping simulated and real drivers. Malleable VIs accept different data types and adapt their diagram to them.

VI Package Manager and NI Package Manager

Reusable code, from tools to frameworks, is distributed as packages:

  • VI Package Manager (VIPM) from JKI: a catalogue of community and commercial packages. Packages are installed into LabVIEW's palette; your own code can be built into a .vip file from a package configuration that lists the files, dependencies, palettes and a version number.
  • NI Package Manager (NIPM) manages NI software and drivers.
  • Dependencies record version ranges so a package that needs another one at 2.x or higher is installed correctly.
Python Choosing a version that satisfies dependencies

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Source control

Use a version control system: Git is the most common, Subversion and Perforce also work. Everything in a project folder goes into the repository: .lvproj, .vi, .ctl, .lvlib, .lvclass, build specs. Not in the repository: build output, *.aliases, *.lvlps (project state), compiled object code.

Practical details:

  • VIs are binary files. Git cannot merge them like text. Treat a VI as owned by one person at a time and use short-lived branches; communicate which VIs you are editing. Configure LabVIEW's Environment options > Source Control with the Git provider, and use Diff (LVCompare) and Merge (LVMerge) tools, which can compare VIs graphically. In Git's .gitattributes, mark VIs as binary: *.vi binary.
  • Separate compiled code from source: enable Separate compiled code from source file (VI Properties > General or Tools > Options > Environment) so a recompile caused by an open does not change the file. Mark it for the whole project via the environment option. This eliminates many meaningless diffs.
  • Commit often, in small pieces. One logical change per commit and a clear message.
  • Tag releases (v1.2.0) and use the tag when building so you can rebuild the same version later.
Python Text diffs versus binary diffs (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A typical team workflow

  1. Create a repository and add the project; add .gitignore for build outputs.
  2. Each developer creates a branch for a feature or bug fix.
  3. Edit one VI area at a time; use LabVIEW's diff tool in code review.
  4. Run unit tests and the VI Analyzer before opening a pull request.
  5. Merge to main, tag a release, build the executable and installer from the tag.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main benefit of putting VIs in a .lvlib?

    Library membership gives qualified names and lets you hide private VIs.
  2. 2. What is a packed project library?

    A .lvlibp is a compiled, single-file form of a library.
  3. 3. Why is merging VIs in Git difficult?

    Use ownership, short branches and LabVIEW's diff and merge tools.
  4. 4. What does 'separate compiled code from source' achieve?

    Compiled code is kept in a cache, so opening a VI does not alter its file.

Summary

  • Use projects, folders and .lvlib libraries for structure and namespaces.
  • Packed project libraries freeze and protect reusable code.
  • Share code through VIPM packages with version ranges.
  • Treat VIs as binary files in Git: small branches, clear ownership, separate compiled code from source.

Next: Performance and Memory