Building C/C++ Applications for NI Linux Real-Time


This tutorial is part of a series that describes software architectures for targeting NI Linux Real-Time hardware. Consider reading Choosing a Software Architecture for Programming NI Linux Real-Time Applications to learn about real-time concepts and design patterns. Continue reading to learn about the steps necessary to start writing an NI Linux Real-Time application in C/C++ and using the LabVIEW FPGA Module.


With NI Linux Real-Time, you can develop, debug, and deploy applications to the open embedded processor written entirely in C or C++ using Eclipse or any other development environment while gaining the benefits of LabVIEW for programming the FPGA. The FPGA Interface C API provides a communication layer between the FPGA and real-time application for I/O control and data streaming. This offers an interface for accessing FPGA controls, indicators, DMA FIFOs, interrupts, and arrays. 


Figure 1. Use C/C++ to develop your NI Linux Real-Time application, LabVIEW FPGA to design custom FPGA personalities, and the FPGA C Interface API for communication between the two.

Introduction to NI Linux Real-Time

Over the last decade, NI has supported several real-time operating systems (RTOSs) with the LabVIEW Real-Time Module. However, none of them received the level of in-house R&D investment, external collaboration, and market reception that NI Linux Real-Time represents. Before getting started with your real-time software development, it is valuable to understand the background, benefits, and performance considerations behind NI Linux Real-Time.

Because of its open-source and community-developed nature, Linux has developed a strong presence in the embedded system design field. Its ubiquity is based off the diverse IP and applications available both within proprietary repositories and on the web. Historically, however, most embedded Linux solutions lacked the reliability and determinism that an RTOS offers; this meant that they were unsuitable for executing event response, closed-loop control, and embedded monitoring applications. NI Linux Real-Time brings together the real-time and Linux worlds, giving you the ability to take advantage of the vast ecosystem of in-house and public Linux IP in your real-time embedded systems. To gain further insight about this unique convergence between real-time and Linux, see the Introduction to NI Linux Real-Time.

If you are already proficient in Linux and interested in learning how to use functionality like Linux shell commands, file transfer over FTP, or command line execution on NI targets, read Under the Hood of NI Linux Real-Time. NI also maintains an active Community page where NI Linux Real-Time developers exchange example code, upload tutorials, and ask questions about a variety of topics.

C/C++ Toolchain Setup

To target NI Linux Real-Time in C/C++, you need the following tools:

  • Development environment
  • Cross compiler, which compiles code developed on a Microsoft Windows or Linux machine for NI Linux Real-Time targets
  • Debugger that can attach to the application running on the real-time target
  • Analysis and signal processing libraries designed for use in real-time systems configured for re-entrancy and shared resource management

NI provides a single installer that bundles the cross compiler along with the Eclipse integrated development environment (IDE) and GNU debugger called C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition (2013, 2014-2016, and 2017-2018 versions available). Refer to Getting Started With C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition for an introduction to this package.

If you prefer to use your own development environment, remember to install the appropriate cross compiler for your development and target systems. Choose the cross compiler for your ARM-based or x64-based real-time target:

FPGA Design

With the upfront choices of real-time software architecture and development tools resolved, many developers choose to start designing their embedded system at the I/O level. For NI embedded hardware, I/O ports are routed through FPGAs, or silicon chips whose gates can be reconfigured in software. Because the chip’s configuration is a physical manifestation of your software design, it requires no operating system to execute; this means the FPGA delivers the highest degree of reliability and fastest response time in your system.


Describe FPGA functionality graphically with LabVIEW FPGA

Figure 2: Describe FPGA functionality graphically with LabVIEW FPGA.


Depending on your application needs, you may want to route I/O straight through the FPGA to the real-time processor or incorporate custom timing, control, and signal processing algorithms at the FPGA level. You can also use third-party IP from Xilinx or the NI community in your FPGA code. Whichever design you choose, the LabVIEW FPGA Module is the method with which you target the FPGA in your NI hardware. Unlike traditional hardware description languages like VHDL or Verilog, LabVIEW FPGA gives you the ability to describe the FPGA functionality graphically; this complements the parallel nature of FPGA processors. 

»View Getting Started With LabVIEW FPGA for an introduction to various functions

Communication Layer: FPGA Interface C API

After you have defined your target’s FPGA personality, you need a way to communicate with it from your real-time application written in C/C++. The FPGA Interface C API is the tool that provides this link. It supports communication between the real-time host application and FPGA via variables that represent controls and indicators on the LabVIEW FPGA VI and through DMA FIFOs.

The FPGA Interface C API generates C header files based on the LabVIEW FPGA bitfile; you can then pull these generated files into your C project to interface with the FPGA registers. The tool must be downloaded separately from and includes extensive documentation.

Next Steps

Community: NI Linux Real-Time

Discussion Forums: Real-Time Measurement and Control


The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a worldwide basis.