Community Documents

Showing results for 
Search instead for 
Did you mean: 

Use Eclipse to Develop C models for Linux-Real Time Controllers Running NI VeriStand or the LabVIEW Model Interface Toolkit

Note: For NI VeriStand Model Framework, Eclipse is still the recommended IDE. For most other use cases, NI no longer recommends using Eclipse. For the most up-to-date C/C++ Tutorials for NI Linux Real-Time, visit and enter the Info Code NILRTCrossCompile.




NI VeriStand ships with the NI VeriStand Model Framework, which allows users to compile 3rd-party models so they can be run with NI VeriStand and the LabVIEW Model Interface Toolkit. Starting in 2015, VeriStand supports both Intel x64-based and ARM-based targets. As NI provides the C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition, some may want to use the Eclipse environment to compile C models for their NI Linux Real-Time targets. This post will walk through how to set up a project in Eclipse and compile a VeriStand-compatible shared object library.


VeriStand Model Framework Installation


If you haven't already, install the NI VeriStand Model Framework from the NI VeriStand installation media.




Creating an Eclipse Project


1. Open Eclipse, and navigate to File » New » C Project and choose a Shared Library project using the Cross GCC Toolchain


Project Setup.PNG


2. Select both Debug and Release configurations for creation


2016-01-29 11_57_23-Photos.png


3. When prompted to configure the Cross GCC path and prefix, refer to steps 13 and 14 in this guide:


Getting Started with C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition


Note: The <National Instruments> tag in the above paths should be replaced with C:\Program Files\National Instruments\ on 32-bit Windows installations, and C:\Program Files (x86)\National Instruments\ on 64-bit Windows installations.


The following screenshot represents the setup for an Intel x64-based target.  For ARM, it will have a different prefix and path than shown.


2016-01-29 14_11_04-C_C++ - Eclipse.png


4. Once your new project has been added to the Project Explorer, please create a new Source Folder and add the model code you wish to compile. As highlighted in the NI VeriStand Model Framework Introductory document, you will need to import the ni_modelframework.h, ni_modelframework.c, model.h, and model.c files before you can compile your model. In Eclipse, right-click the newly created Source folder >> Import... >> File System


2016-01-29 12_12_57-Photos.png


And add the files specified above


2016-01-29 12_13_38-Photos.png


Please note that further information concerning modifying your C model to fit the VeriStand Model Framework is available in the previously mentioned document.  When completed, your Project Explorer pane should look like the screenshot below.


Files Added.PNG


Configuring Eclipse Build Settings


Note: For the following steps, if you chose to create both Debug and Release Configurations, you will need to add the options to both configurations. using the Configuration: drop-down at the top of each settings page.


1. Instead of relying on the makefile described in the NI VeriStand Model Framework documentation, you can use the automatically generated makefiles if your project is configured appropriately. First, right click on your project name in the Project Explorer and navigate to Properties. Under C/C++ Build, go to the Tool Chain Editor. Uncheck the Display compatible toolchains only box and select CDT Internal Builder as the Current Builder. Then press Apply.


Set Internal Builder.PNG


2. To avoid needing an external makefile, navigate to C/C++ General»Paths and Symbols in the Project Properties window. Once there, go to the Symbols tab and select Add. Enter a symbol of Name kNIOSLinux and press OK, then press Apply.




3. Again in the project properties window, navigate to C/C++ Build»Settings and then go the Tool Settings»Cross GCC Compiler»Miscellaneous section. Please select the Position Independent Code option and press Apply.




4. Go to C/C++ Build»Settings and then go the Error Parsers tab. Here, please make sure that only the GNU Assembler Error Parser, GNU gmake Error Parser 7.0, and the GNU Linker Error Parser options are selected and press Apply:


error parsers.PNG


5. Lastly, go to C/C++ Build»Settings»Cross GCC Compiler and add the compiler command -fvisibility=protected to instruct GCC to set the symbol visibility to protected.


2016-01-29 12_49_49-Properties for EngineModel.png


Now you can build your model by right-clicking on the project name in the Project Explorer and selecting Build Project.


Once you have compiled your model, you can add it to your NI VeriStand System Definition file or to your LabVIEW VI using the Model Interface Toolkit.


Example Eclipse Projects


Attached to this post, you can find two different Eclipse projects and the corresponding source code. contains an Eclipse project that can compile the shipping example Sinewave model (C:\VeriStand\2015\ModelInterface\custom\examples\sinewave)  for Intel x64-based targets. contains an Eclipse project that can compile the shipping example Engine model (C:\VeriStand\2015\ModelInterface\custom\examples\engine) for ARM-based targets.


To add these projects to Eclipse, go to File»Import and select Existing Projects into Workspace. When selecting the root directory, please select the extracted top-level directory of the model in question.

Download All

When configuring your Eclipse build settings for VeriStand 2017, use the C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition 2017.


Also, it is necessary to specify the path to the sysroot, which is the logical root directory for headers and libraries. This can be done by follow step 9 of Creating a Build of a C/C++ Project in the Getting Started with C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition.