Running a LabVIEW Application on Linux Without a Graphical User Interface

Updated Apr 2, 2018

Reported In

Software

  • LabVIEW

Operating System

  • Linux

Issue Details

I need to run my LabVIEW application on Linux without having an X Display.  When I try and run my executable built in LabVIEW now, I get an Unable to open X display error.

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.
  1. Create a Shared Library from the LabVIEW project containing your VIs by right clicking on Build Specifications and selecting New » Shared Library.
  2. 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.
  3. When the Define VI Prototype window appears, note the Function Name, and verify that the options match the image below, then click OK.
  1. 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).
  2. 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.
  3. 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;
}
  1. 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>
  1. You should now be able to run the command ./TEST which will execute your LabVIEW code without the need of a GUI.

Additional Information

For LabVIEW 2017 and 2017 SP1, you will need to add the flags -ldl and -lstdc++ to include the proper C++ libraries for the compilation to work properly. For shared objects built by other versions of LabVIEW, these libraries are included by default:


 

WAS THIS ARTICLE HELPFUL?

Not Helpful