Separate Compiled Code from Source
VI Properties: Separate compiled code from source file

Separate Compiled Code from Source

[This article was originally published on our Company Blog]

Usually, LabVIEW stores the compiled code used to run a VI together with the graphical code of the VI in the same file. LabVIEW automatically recompiles all changed VIs together with all callers, modifying a lot more files than were actually touched. Your SCC won’t like that! Luckily, there’s an option to separate the compiled code from the graphical source code. 

Why bother?

At the ALA Summit last November, we touched on the topic of the “separate compiled code” option in LabVIEW. Another little discussion yesterday on one of the ALA Slack channels sparked the idea of this article. Here’s a little refresher as to why it is a good idea to enable this useful option:

When you change a VI, LabVIEW will update all VIs that have this changed VI as a dependency, and recompile every VI hat is calling that VI, and every VI that is calling the calling VIs, and so on. That’s why you end up with so many “dirty dots”. Technically, LabVIEW does not really change the VIs (i.e. the front panel or block diagram) but only recreate the compiled code for it, which by default is stored together with the front panel and the block diagram in the same VI file.

As long as you’re not using Source Code Control, it’s not too much of a bother as you don’t need to do anything but say “Save all”. When you use SCC, though, it will want to update all the VIs that changed on disk, so you lose track of which VIs you actually modified.

Thankfully, you can tell LabVIEW to “Separate compiled code from source file”, which will do exactly as it says: It stores the compiled code somewhere else (in the compiled object cache).

Pros

  • This feature makes it possible to leverage all the advantages of source code control with LabVIEW, when developing large applications and/or in teams, or even a small application on your own (thanks, Danny Thomson, for pointing out the importance)
  • No dirty dots, hence no unintended side effects in SCC
  • Fewer merge conflicts as code on a parent/top-level or shared resources don’t change (thanks, @thoric)
  • Faster load times for source-only VIs (besides the first recompilation, see below)

Cons

  • The first time you open / load the VI, it takes longer as LabVIEW needs to recompile
  • VIs without compiled code cannot be used in the runtime environment, so if you make an application with plug and play extensions, loaded dynamically from file, the extension VIs need to have compiled code in them (thanks again, @thoric) (edit: Alex points out in the comments that building the source into a packed project library addresses this issue)
  • Potential problems: When deploying to Real-Time targets, and/or when deploying updated FPGA bit files, it happened to us a lot that LabVIEW would not actually notice that files changed, and would not deploy correctly. Clearing the compiled object cache seems to help with this and other oddities.

Enable The Options

There are different ways to enable this feature. For a single VI (or library or class), you can change this setting in the Properties dialog in the General Settings tab (see screenshot above). 

You can also configure your project file to separate the compiled code from new project items and mark existing items, too:

Separate Compiled Code From New Project Items

Finally, you can tell LabVIEW to separate the compiled code from all new files. The setting can be found in the “Environment” section of the Options dialogue (menu “Tools” -> “Options…”):

Separate Compiled Code From New Files

Check Existing Files

There’s also a VI Analyzer test that checks for this setting in the VI Analyzer Enthusiasts group. Make sure to browse the listing of available community-created VI Analyzer tests while you’re there!

Modify Existing Files

If you want to scan your existing files for VIs or libraries or classes that miss this setting, and also programmatically enable the option for those files, you can use a little scripting VI that we came up with. You can find the VI in our public hse-scripting-tools repository:


Would be interesting to see the results.

Like
Reply

I don't understand why this is not enabled by default. Also I would believe your con is not correct: 'VIs without compiled code cannot be used in the runtime environment'. While that is true, it is not the intention that you should deploy source code on a run time system. For the example you mention on plug-ins, I believe the correct approach is to build the source into a library and then you can still use the plug-in method. Separating the compiled code will automatically lead to better software as you are forced to think about how you deploy.

When this first came out i had so many issues with it. Has it improved for medium to large scale projects?

Like
Reply

That feature was a game changer when it came out.  I still run into people who don't know about it.  Thanks for spreading the word!

To view or add a comment, sign in

More articles by 🕺🏻 Joerg Hampel

  • HSE Wins Consultant Impact Award 2025

    During NI Connect 2025 in Fort Worth, Texas, Hampel Software Engineering was honoured with NI’s 2025 Consultant Impact…

    14 Comments
  • Why to sit for a LabVIEW Certification? (Ode to CLA Summits)

    For LabVIEW developers, there are a number of interesting certification programs out there. For obvious reasons, NI's…

    7 Comments
  • Why DQMH®?

    Disclaimer: This article is meant to discuss the benefits and advantages we (Hampel Software Engineering) experience on…

  • Motivation

    There are various definitions of success, and the ones I like revolve around the topic of happiness. Having fun doesn’t…

  • NI Center of Excellence

    At the end of 2019, Hampel Software Engineering became an NI accredited Center of Excellence, making us the first in…

    7 Comments
  • Why Git Tower...

    ..

    9 Comments
  • LabVIEW Community Edition

    This surprise was definitely not expected by anybody in the audience of GDevCon#2: NI announced LabVIEW Community…

    1 Comment
  • Why GitLab?

    I've been wanting to write an article on LinkedIn for quite some time. Danny Thomson recently asked why I chose GitLab…

    10 Comments

Others also viewed

Explore content categories