In my opinion, LabVIEW Libraries are one of the biggest productivity improvements in LabVIEW. Consequently, most of our template code is organised into LabVIEW Libraries (.lvlib) or Packed Project Libraries (.lvlibp). These, therefore, allow developers to easily package, distribute and organise code modules.

For Metis Automation, a typical library is a fully functional code module. That is, a queued message handler that does one specific task e.g. acquire DAQ inputs, log data to disk, or communicate with a hardware device. It may also just be a group of sub vi’s that do a specific function. Once packaged into a library, we can thereafter benefit from several features:

Public and Private Scope

Libraries allow the developer to set the access scope of functions within the library. The main scopes are Public and Private:

  • Public – The sub Vi can be used inside or outside of the library
  • Private – The sub vi can only be used inside the library

This is useful when trying to reduce coupling between sections of your software application. By setting the scope to private, it means the Private sub vi’s cannot be called from external code. This helps to enforce modular, loosely coupled software that is as a result, easier to debug and maintain.

Template LabVIEW Libraries

Most of our code templates are organised into libraries in a central, reusable code repository. When starting a new project or adding a new feature to an existing project, our first step is to look for a template library that is a good starting point for this new feature.

LabVIEW Libraries

Creating a new module for a project from a template library.

By organising this code into libraries, it is easy to copy, move and organise our template code as it gets moved into a new project.

Name Spacing

In the final example of using code templates for various tasks, it would not work as smoothly if there were duplicated names in our templates. For example, LabVIEW will “error” if we have more than one function named in our project. It will think there is a conflict. Libraries, however, provide namespacing which solves this issue. If you were to make 2 copies of a template, Library 1 and Library 2, the function will be named as follows:



LabVIEW Libraries

LabVIEW Libraries provide namespacing to all functions within the library

This is a big benefit as you no longer have to rename all of your new code created from the template or add namespacing manually.