Build C/C++ Models for VeriStand on Any Target OS With Command Line

Updated Apr 7, 2025

Environment

Software

  • VeriStand

Programming Language

  • C
  • C++

C and C++ are widely-used programming languages, often employed to create simulation models. These models can be built to be compatible with VeriStand using the VeriStand Model Framework.

 

This article provides a step-by-step guide on how to build C or C++ based models into VeriStand-compatible models. It does not cover the VeriStand Model Generation Support MATLAB® Add-on. The article is organized according to the different operating systems VeriStand can deploy applications to: Windows, Pharlap, and Linux Real-Time.

 

MATLAB® is a registered trademark of MathWorks, Inc.

There are three main steps to build a C/C++ model compatible with VeriStand:

 

1. Install the Required Software

 

2. Adapt Your C/C++ Code for Building a VeriStand Model

    • Create a model.h header file.
    • Adapt template.c to serve as your model code.
    • Create a makefile to compile your model code.

 

For more details on these steps, consult the NI VeriStand Model Framework documentation.

 

3. Compile the Model with NI VeriStand Model Framework and Command Prompt Tools

 

Windows and PharLap Targets:

    • Open the Developer Command Prompt for VS 2022 through the Start menu or by executing VsDevCmd.bat located at: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools.
    • Set the appropriate environment based on host PC and target architecture:
      • Call VsDevCmd.bat with defined host_arch and arch arguments. For example, VsDevCmd.bat -host_arch=amd64 -arch=amd64 is used to compile the model for a 64-bit system using a likewise system as the host. Architectures available can be found in Use the Microsoft C++ toolset from the command line | Microsoft Learn.
      • Alternatively, you can use the Developer command prompt shortcuts or predefined configurations located at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build, instead of VsDevCmd.bat.
    • Navigate to the location of the model source files, for example: cd C:\VeriStand\2021\ModelInterface\custom\examples\engine.
    • Use nmake with the corresponding makefile, for example: nmake engine.mak.

 

    • Navigate to the folder where the files are located and look for the .dll file. This file is the successful build you can import into VeriStand to run this model.

 

Linux RT 64-bit Targets:

    • Open the command line or the Developer Command Prompt and execute the setup script: C:\VeriStand\2021\ModelInterface\tmw\toolchain\Linux_64_GNU_Setup.bat.
    • Navigate to the location of the model source files: cd C:\VeriStand\2021\ModelInterface\custom\examples\engine.
    • Execute cs-make.exe with the makefile: cs-make.exe -f engine-linux64.mk.

 

    • Navigate to the folder where the files are located and search for the .so file. This file is the built model that you can import into VeriStand.

 

Linux RT 32-bit ARM Targets:

    • Open the command line and execute the setup script: C:\VeriStand\2021\ModelInterface\tmw\toolchain\Linux_ARM_32_GNU_Setup.bat.
    • Navigate to the location of the model source files: cd C:\VeriStand\2021\ModelInterface\custom\examples\engine.
    • Execute cs-make.exe with the makefile: cs-make.exe -f engine-linux.mk.
    • Navigate to the folder where the files are located and search for the .so file. This file is the built model that you can import into VeriStand.

 

Note: Make sure to move your .so file out of the source code folder before building for a second OS. Otherwise, there is a chance that building a second time will conflict with the first build.