08-03-2009 01:40 PM
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
08-04-2009 09:08 AM - edited 08-04-2009 09:09 AM
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.
08-04-2009 03:02 PM
08-05-2009 06:10 PM
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).
03-12-2014 10:21 AM
@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.
03-12-2014 10:35 AM
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.
03-12-2014 12:38 PM
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:
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:
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
03-13-2014 05:50 AM - edited 03-13-2014 05:55 AM
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.
I think there is a semi-documented way to hook into the Application Build tool, to have VIs execute as PreBuild steps.
02-03-2015 08:13 AM
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).
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
03-06-2017 04:47 PM
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