Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

Running a LabVIEW application on Linux without an X Display

Primary Software: LabVIEW Development Systems>>LabVIEW Professional Development System
Primary Software Version: 8.5
Primary Software Fixed Version: N/A
Secondary Software: LabVIEW Run-Time Engine

Problem:
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.


     
  4. Now select the Advanced section and check the box for Use embedded version of run-time engine.
     
  5. 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.
     
  6. 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;
    }

     
  7. After saving the C file, compile the application using the following gcc command where TEST is the name of the application you want to generate.  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 -g -o TEST test.c ./SharedLib.so -L /usr/local/natinst/LabVIEW-8.5/AppLibs/liblvrtdark.so.8.5
     
  8. You should now be able to run the command ./TEST which will execute your LabVIEW code without the need of a GUI.


Related Links:
KnowledgeBase 3PMCHLHY: Do I Need a GUI Such as KDE or GNOME to Use a LabVIEW Executable in Linux or UNIX?

Attachments:
LabVIEW_No_GUI.zip




Report Date: 05/14/2008
Last Updated: 05/14/2008
Document ID: 4LDD75PO

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit