Solution
The LabVIEW Run-time Engine must be present and running in order to use a LabVIEW Executable. Dependancies exist between the LabVIEW Run-time Engine and a GUI environment. For this reason, LabVIEW executables and libraries also require a GUI such as KDE, GNOME, or X-Windows to run.
In order to compile LabVIEW VIs and run them without using a GUI, you must compile them as a Linux Shared Library instead of as an Executable. The Shared Library will allow you to use an embedded version of the LabVIEW Run-Time Engine. After building the Shared Libarary, you can call it using a simple C application.
- Create a Shared Library from the LabVIEW project containing your VIs by right clicking on Build Specifications and selecting New » Shared Library.
- In the window that appears, navigate to the Source Files section, select the main VI that you want to run and add it to the Exported VIs section.
- When the Define VI Prototype window appears, note the Function Name, and verify that the options match the image below, then click OK.
- Now select the Advanced section and check the box for Use embedded version of run-time engine (Note: this option is only available in LabVIEW for Linux).
- Make any other changes you would like to the Shared Library configuration, and then click Build at the bottom of the window. This will generate a number of files including a .h and a .so file.
- In the same directory as the .h and the .so files, create a new C file (test.c in this example) with the following contents.
Note: You will need to replace SharedLib.h with the name of your .h file and Test() with the name of the main function that you set for the main VI in the Shared Library build specification.
#include "SharedLib.h"
int main()
{
Test();
return 0;
}
- After saving the C file, compile the application using the following example of a gcc command where <options> is where you can include any other options you may need, FILENAME is the name of the application you want to generate and <path to RTE> is the path to your LabVIEW Run-Time Engine. This builds an application out of the C file you have just written, the shared library created from your VI, and the "dark" (i.e. no display) LabVIEW Run-Time Engine.
gcc <options> -o FILENAME test.c ./SharedLibFromVI.so -L <path to RTE>
- You should now be able to run the command ./TEST which will execute your LabVIEW code without the need of a GUI.