The MacView

Virtual Instrumentation from a Mac perspective

Wednesday, February 27, 2013

Build a Standalone Mac App in LabVIEW (no need to install the Runtime)

I just posted an example VI that Installs the LabVIEW Runtime Engine into your built apps. LabVIEW has added pre/post action VIs that you can add to your Build Application Specification. This can be very useful for automating prep-work or post-build tweaks.

One thing I have found that not many people are aware of is that you can embed the Runtime Engine in your LabVIEW built application. Since applications on the Mac are just folder (right click or control-click on an app and select Show package contents) you just need to create a folder inside your built app called "Support". Put the appropriate version of the LabVIEW Runtime Engine in that folder and now there is no need to include the LabVIEW Runtime Engine Installer.
Now the Runtime Engine is quite large (159MB for 2012), and some of that is due to items that you may not need. For some things it's obvious if you need it or not (if you're not using MathScript, you can delete the MathScript framework). Some things, if you delete them, can prevent the application from launching or working correctly. The VI I cooked up not only installs the correct version of the Runtime Engine (installed on your machine) but it also removes everything that is not needed to launch a simple VI.

Another reason the Runtime Engine is large is because there may be more than one architecture in the libraries. On the Mac, you can have what is called Universal Binaries, which includes native executable code for more than one processor in the same file. We have done this in the past to allow PowerPC and Intel code coexist in the same file. Some of our libraries may contain vestigial PowerPC code. If, in the future, LabVIEW were to support 64-bit Intel, it might have both 32-bit Intel and 64-bit Intel in the same binary. This VI also goes through every library in the Runtime Engine and strips out any code that is not 32-bit Intel.

We also ship a good amount of information in LabVIEW executable code to help us diagnose problems on users machines. You probably don't need all that diagnostic code, so in addition to installing the Runtime Engine, stripping out non-32-bit executable code, the VI also strips out any information that would help in diagnosing problems.

The Install Runtime Engine.vi also zips up your .app instal a zip file right next to the app (using the maximum zip compression). That way you have a standalone application in a zip file you can email or post to a web server, ftp site, or however you want to distribute your app.

Oh, and you know those annoying .aliases and Preferences files that are always dumped next to your app? Well, this post-build step VI will also remove those for you, leaving just the app and the zip file of the app.

Use this VI as a starting point. Modify it, hack it up, improve it. Please leave comments below of any recommended improvements or cool tricks you found for post-build steps.



Labels: , , , , , ,

9 Comments:

Blogger Ryan Godwin said...

Hi Marc,

First off, thanks for the VI! It certainly will make my life much easier, that is if I can get it to work properly. While I did modify it slightly to prevent it from deleting included configuration files and the like, I see that the runtime engine is correctly dded to the application directory upon building. However, when I try to run this app on a machine without the runtime engine already installed, I get an error saying there is no runtime engine. I've dug into the app directories and found the runtime engine, but it does not execute...

I am running on Mac OS X 10.8.4 using LV 2012. Any help you can provide will be much appreciated!

Ryan

Monday, July 29, 2013 8:29:00 AM  
Blogger Jeremy Willden said...

Thanks, Marc, very helpful.

Saturday, January 04, 2014 5:46:00 PM  
Blogger Marc Page said...

Hey, Jeremy. Thanks so much. Great to hear from you.

Monday, January 06, 2014 6:34:00 AM  
Blogger SK said...

This comment has been removed by the author.

Friday, October 17, 2014 10:30:00 AM  
Blogger SK said...

This comment has been removed by the author.

Friday, October 17, 2014 10:31:00 AM  
Blogger SK said...

Sorry, had internet issues. Let me describe my scenario better. I have a simple project that uses LabVIEW 2013 and Visa 5.3/5.4. I'd like to distribute this as a stand-alone app to somebody who's never touched LabVIEW. I've used your instructions to package LabVIEW runtime and it works great (Thanks !). I tried to copy Visa.Framework into my /support folder but it still doesn't work. I installed Visa runtime on my Mac OS (Mavericks) and my app works. So is there something else that needs to be done ? Thanks a lot for your help and article.

Friday, October 17, 2014 10:46:00 AM  
Blogger Marc Page said...

SK,

Unfortunately, drivers (like VISA) will need to be installed. There are some advanced techniques you can use where you embed the VISA installer in your application and if VISA is not detected on the machine, run the installer.

Tuesday, October 21, 2014 6:41:00 AM  
Blogger A.P. Shepherd said...

Marc, this is what I recently posted on one of NI's websites. If you know the answer, please let me know. I'll always be grateful to you for Install Runtime Engine.vi.

Re: Can compiled LabView programs be sold on Mac App Store?
A.P._Shepherd
Member A.P._Shepherd MEMBER
‎05-24-2017 07:37 AM
Options
An employee of NI, MARC PAGE, has created Install Runtime Engine.vi which has been wonderful. I can use it to create a single, complete Mac program for teaching physiology. It has the runtime engine already installed. That makes it easy to download and install for people who don't know a lot about those things and who have never heard of a "runtime engine".

Now we're back to the original question: "Can compiled LabView programs be sold on Mac App Store?", and the answer will depend on Apple's business policy and their relationship with NI.

If you know the answer, please email Pete (sangrelux@gmail.com).

Wednesday, May 24, 2017 5:50:00 AM  
Blogger A.P. Shepherd said...

Thanks a lot!

Wednesday, May 24, 2017 5:51:00 AM  

Post a Comment

<< Home

The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of my employer.