LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determining the version of an executable under Linux

I am trying to programatically obtain the version of an executable under Linux.  There is information about doing this under Windows here:

 

http://digital.ni.com/public.nsf/allkb/935BA7FB426305398625711E0055F1FA

 

which tells me to go to 


<LabVIEW >\vi.lib\Platform\fileVersionInfo.llb

 

but this is for Windows.  When I look on my Linux machine, the  <LabVIEW >/vi.lib/Platform directory contains only

 

CCompileSupp.llb

browser.llb

<express>

<idfinder>

system.llb

 

Is it possible to get the version number under Linux?

 

Thank you for any assistance you can offer.

 

-Chris

0 Kudos
Message 1 of 12
(15,138 Views)

I'm in doubt about that.

 

Windows uses its own format to store binary resources like version number, author etc. in executable files

and its own API to retrieve these information.

 

AFAIK there's no standard format to store resources in Linux ELF binaries and I don't know whether NI has implemented something special for LV but since the article you mentioned is Windows only I'm afraid that this feature doesn't exist in LV for Linux.

 

Message Edited by candidus on 08-04-2009 09:09 AM
Message 2 of 12
(15,121 Views)
Bummer.  Well, thank you anyway.  I'll see what I can do for a work-around.
0 Kudos
Message 3 of 12
(15,109 Views)

If you still need a workaround, here is an idea:

 

Create a simple VI which just returns the version number.

Use that in your application whenever you need it, e.g. to display an about box.

If you want to know the version number from outside your application call that VI dynamically.

 

I've attached you a small example (created in LV 6.1 on Linux).

 

 

 

 

 

0 Kudos
Message 4 of 12
(15,090 Views)

@candidus wrote:

If you still need a workaround, here is an idea:

 

Create a simple VI which just returns the version number.

Use that in your application whenever you need it, e.g. to display an about box.

If you want to know the version number from outside your application call that VI dynamically.

 

I've attached you a small example (created in LV 6.1 on Linux).

 

 

 

 

 


Candidus,

 

In your example the version number is hardcoded, so it is not what we are looking for. We need to get the version of the executable file at run time.

So fare I can't find a good way yo get this in Linux.

0 Kudos
Message 5 of 12
(14,424 Views)

You're right, it is an ugly workaround.

 

Windows executables uses embedded resources that contain the version number but linux executables (ELF binaries) don't have version resources or an internal version number. It's up to the programmer to handle version numbers.

The platform doesn't support them.

 

0 Kudos
Message 6 of 12
(14,412 Views)

Are you trying to get the Version Number that is created as part of the Build Executable process?  I'm assuming that Linux LabVIEW allows you to specify Version as part of the Build, but that you don't have a way (at Run Time) of retrieving this value.  I also realize that you don't want to write a "Constant" VI that simply returns the current Version number whenever it is called (as that requires additional "programming maintenance").

 

One possible "fix" is to combine the two approaches.  You can write a VI that will interrogate your Project, extract the Version parameters stored in your Build Executable command, and update the "Version VI" for you.  You may need LabVIEW Scripting to do this (when I tried it, I used Scripting, but there may be another way), but you can "guard" this code so that it doesn't run when run as a Top Level Executable.

 

Here's how it (could) work.  You write a VI called something like "Update Version from Build" that does the following:

  1. Checks if running as Executable, or in Development Mode.  Continue only if Development Mode.
  2. Open a Project Property Node and get the Active Project (this requires Scripting).
  3. Get a list of Build Specs from your Target.  Look at the Owned Items and find the Build Spec whose Version you want.
  4. Get the Tags for the Version parameters.  The Tags you want are TgfF_fileVersion.major, TftF_fileVersion.minor, TftF_fileVersion.patch (or .fix, not sure when you use which, or if one is obsolete), and TftF_fileVersion.build.
  5. Assemble these four numbers as you wish (a dotted string, an array of 4 integers, whatever).
  6. Get a VI Reference to your Version VI.  Use the Control Value Set method (Invoke Node) to set the Version indicator (which should be the only thing in this VI).
  7. Use the Default Value, Make Current Default method to make this value "stick", then use the Save Instrument method to save the Version VI.

In your program, put this Update Version from Build VI somewhere early (in Initialization).  Whenever you need to access, or display, the Version, just call the Version VI and it will give you the (saved) Version.

 

When you go to build your Executable, you need to do things in the right order.  Proceed as follows:

  1. Configure your Build.  Set the Version Info to whatever is the "correct" value.
  2. Do not do the Build yet, as the Version VI in your code has not (yet) been updated.
  3. Run your program (in Development Mode) once, at least as far as the Update Version from Build VI.  Now your Version VI "matches" the version in the Build.
  4. Build your Executable.

It's a number of steps, but not that difficult (once you write the required VIs, which you do only once).  Just remember to Build, run-in-Development, and Build (again) to keep the Version(s) consistent.  Should work with any OS (as LabVIEW is saving the Version Info inside the Project).

 

Bob Schor

0 Kudos
Message 7 of 12
(14,401 Views)

The version information in the Build properties is most likely not used at all in the Application Build inside LabVIEW for Linux, since the platform doesn't support a generally accepted means to store that information. Not sure either if it is actually used on LabVIEW for OSX, which would support version information as it implements the MacOS file resource format partly, which is where Windows got the idea from. Smiley Very Happy

 

I think there is a semi-documented way to hook into the Application Build tool, to have VIs execute as PreBuild steps.

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 12
(14,377 Views)

Hello,

 

I found this thread because I'm having the same issue.  I want to include the build version information in the binaries under Linux.  My solution is pretty much the same as Bob_Schor but the tags name are different and I'm calling the following VI's from the "Pre Build Action" VI when building my application.  In the "Pre Build Action" VI template we get the Project path and the build specification name, so I made the following VI to get the build version information when building my application.  I then save the build version information into a global variable programmatically also in the "Pre Build Action". See the code below (it's working on my side under Linux, the description of my distribution is below).

 

GetBuildVersionInformation.png

 

 

SetVersionInformation.png

 

Linux distro:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"
NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"
VERSION_ID="14.04"

 

Michel

Message 9 of 12
(13,986 Views)

I expanded on Michel's solution and packaged it up into an lvlib. My use-case was shoving the build number into a real-time application so it can report to the monitoring PCs which version it's using.

 

To make things simple, I wrote it so it automatically creates a control in your top-level VI(s) called Version (Build-generated) and then saves the version number in there as the default value. It does not affect any of the other default values in the VI(s). On subsequent builds it will skip creation and just update/save the control it if it already exists.

 

Add the lvlib to the My Computer section of your project and select it as the pre-build vi for the RT build.

 

Jody

0 Kudos
Message 10 of 12
(12,601 Views)