Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 36 ยท Environment and VIs

Projects and Libraries

Organize LabVIEW work with project files, virtual folders, libraries, namespaces, access scope and dependencies so large applications stay manageable.

A single VI is easy to manage. Fifty VIs are not, unless you organize them. LabVIEW offers a project (.lvproj) to hold files, targets and build settings, and libraries (.lvlib) to group related VIs behind a shared name. This lesson describes the real tools in words and uses JavaScript stand-ins for name resolution and dependency ordering. No LabVIEW output is shown.

The project

Create one with File > Create Project (or the Getting Started window). The Project Explorer window shows a tree:

  • Project root (the project's name).
  • My Computer: the default target, the machine you develop on. Other targets are added for real-time controllers, FPGA devices or remote systems.
    • Items (VIs and files), Dependencies and Build Specifications.

Add VIs by right-clicking My Computer > Add > File. Use virtual folders to organize them visually; they are only project-tree groupings and do not create folders on disk. Auto-populating folders mirror a real folder on disk and update when files change.

Good habits:

  • Keep the project file in a folder at the root of your source tree.
  • Mirror the project tree in disk folders to avoid confusion.
  • Put Main.vi and reusable code in different folders.
  • Do not mix files from the NI install tree into your own folders; reference them through vi.lib instead.

Why projects matter

  1. A project tracks dependencies: every VI your code calls that is not in the project appears under Dependencies. Unexpected entries often point to a stray VI you called by accident.
  2. The project is the starting point for build specifications (executables, installers); see deployment (a later chapter of this track, see the track page).
  3. It enables conflict detection, such as two VIs with the same name loaded at once.
  4. It allows targets such as real-time devices.

Libraries (.lvlib)

A project library groups VIs, controls, type definitions and other files under one namespace. Create one with right-click on the project > New > Library, then Add items or drag existing ones in.

Benefits:

  • Namespacing. Two libraries can each contain Open.vi. In memory they are Instrument A.lvlib:Open.vi and Instrument B.lvlib:Open.vi, so there is no collision.
  • Access scope. Mark a member Public or Private. Private members can be called only by other members of the same library. Right-click an item in the library and choose Access Scope.
  • Single file for distribution. The library stores the names and references of its members.

A library does not hold the members' code in one file by default; the .lvlib records which VIs belong. If you want one file, use a packed project library (.lvlibp) generated during a build, which is useful for sharing a stable binary.

Organizing files

Project Tree of files and targets
Library Namespace and scope
Build spec EXE, installer
1 / 2

Classes in one paragraph

LabVIEW also has object-oriented programming. A LabVIEW class (.lvclass) is like a library whose data is a private cluster and whose members are methods. Classes support inheritance and dynamic dispatch. You do not need them for your first projects, so this course only mentions them; later chapters use clusters and type definitions (see clusters and type definitions) for the same data-hiding goals.

Search paths and missing VIs

When you open a VI, LabVIEW loads every subVI it calls. It searches the project, then the directory of the caller, then vi.lib, user.lib and instr.lib, then other configured paths. If it cannot find a dependency you see a Loading dialog; browse to the file or choose Ignore if you plan to fix it. Prevent the problem by keeping all code in one project tree and never renaming files outside LabVIEW. Renaming and moving files inside the Project Explorer updates callers automatically, while renaming in Windows Explorer does not.

Source control

VIs are binary files, but LabVIEW integrates with Git, Subversion and others, and has a diff and merge tool (Tools > Compare). Useful habits:

  • Commit the .lvproj and .lvlib together with the VIs.
  • Use a .gitattributes entry to mark VIs as binary.
  • Ignore build output.
  • Use Separate compiled code from source (Tools > Options, or in a VI's properties) so recompilation does not mark every file changed.

Stand-in: namespace-qualified names

This is a model of how libraries prevent naming clashes. It is not NI software.

JS Stand-in: two Open.vi files, no clash

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

No output.

A second stand-in lists a project's dependencies by walking calls, a task LabVIEW does for you in the Dependencies node.

JS Stand-in: find every dependency of Main.vi

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

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a virtual folder in the Project Explorer do?

    Virtual folders are only tree organization; auto-populating folders mirror disk.
  2. 2. What is a main benefit of a project library (.lvlib)?

    Libraries qualify names and allow private members.
  3. 3. Why should you rename or move VIs inside the Project Explorer?

    Renaming outside LabVIEW can leave callers with missing-VI links.
  4. 4. Where do build specifications live?

    Build specifications such as executables and installers are part of the project.

Summary

  • A .lvproj holds files, targets, dependencies and build specifications.
  • Virtual folders organize the tree; auto-populating folders mirror disk.
  • Libraries give VIs a namespace and public/private scope.
  • Rename and move files from within LabVIEW so links stay intact.
  • Configure source control early and separate compiled code from source.

Next: Clean Diagrams and Documentation