Gmake Error 2 When Building Simulink Model for Use in VeriStand

Updated Sep 19, 2023

Reported In

Software

  • VeriStand
  • Simulink
  • MATLAB

Issue Details

I have a Simulink model that I want to use in VeriStand. I installed the VeriStand Model Generation Support MATLAB add-on and followed the installation instructions, including installing the MATLAB MinGW Compiler for 64-bit Windows targets and NI GCC Cross-Compiler for NI Linux Real-Time targets.

I have set the build settings as described in Creating Simulation Models Using VeriStand Model Generation Support Add-On but when trying to build, I get:
gmake: *** No rule to make target `Add-Ons/Toolboxes/VeriStand', needed by `veristand_model_capi.obj'.  Stop.
<Path to model>\Model Name_veristand_rtw>echo The make command returned an error of 2
The make command returned an error of 2
<Path to model>\Model Name_veristand_rtw>exit /B 1
 
untitled1  Failed  Code generation information file does not exist.  
    
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 9.703s
Error: Error(s) encountered while building "Model Name"

Solution

This error occurs due to spaces in the name of the model, or path to the model. 
Whether or not this is supported can depend on PC settings, such as if Windows 8.3 name creation is enabled or disabled. Multiple steps could resolve this issue:
  • Ensure your model does not have any spaces in the model name
  • Ensure there are no spaces in the path to the model. A quick way to do this is to save the model to a simple path such as a folder in your c drive. For example C:\ModelFolder\ModelName.slx
  • If possible, try building the model on another computer (with the add-on and dependencies installed)
  • Try to uninstall and then reinstall the VeriStand Model Generation Support add-on
  • Open NI Package Manager and on the INSTALLED tab search for "" to confirm the 'NI GCC Cross-Compiler for NI Linux Real-Time targets' is installed. If it is not installed, install it. If it is installed, try repairing the package or removing it and then reinstalling it
  • If the error persists after this, try following the steps outlined in The MathWorks documentation: [External Link] Build Process Support for File and Folder Names

If the error continues after trying the steps above then the error is likely being thrown because of a space in the path to the files used by the VeriStand Model Generation Support add-on to build the model. We can resolve this error by moving the files from their default location to a path without any spaces and registering this new location with MATLAB. To do this, follow these steps:
  1. Copy the contents of  "C:\Users\<username>\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\VeriStand Model Generation Support\" to a folder with no spaces in, for example,  "C:/vsmodel/"
    1. Folder contents.png
  2. Once the content is copied over to your new location, uninstall the VeriStand Model Generation Support add-on:
    1. Open MATLAB and navigate to the Home tab
    2. Click on Add-Ons to open the Add-On Explorer
    3. Click Manage Add-Ons in the top right corner
    4. Find VeriStand Model Generation Support in the list and click the three dots and then Uninstall2. Uninstall.png
  3. Now we need to add the path to our new folder (C:\vsmodel for example) to the list of MATLAB paths. 
    1. Open MATLAB and click on the Set Path button on the Home tab
    2. Click on Add Folder and add the following paths:
      1. C:\vsmodel
      2. C:\vsmodel\matlab-support\toolchain
      3. C:\vsmodel\matlab-support\target 3. Paths.png
  4. Finally, restart MATLAB and try building your model again.

Additional Information

Copying the content of the VeriStand Model Generation Support add-on manually and 'uninstalling' the toolbox is not the best practice and should only be done if the other troubleshooting steps failed.