IBM Support

Switching Visual studio compiler for Rhapsody S-Function export to Simulink

Product Documentation


Abstract

For exporting S-Functions to Simulink, Rhapsody first generates the code (with settings for a specified compiler). This generated code is then built by MATLAB using the same compiler and run within SImulink. Therefore, it is critical that the compilers selected in both Rhapsody and MATLAB match in version, architecture and language. This document guides you through the settings required in both applications and then discusses some of the common export errors and their causes.


Content

More information on supported Microsoft® Visual Studio® compilers can be found here.

A. MATLAB® configuration:

  1. In the MATLAB® command window:

    • For C++ type:
      mex -setup C++

    • For C type:
      mex -setup

  2. MATLAB® will give a compiler status report:
     Sim1

    Select the compiler required. For example "Microsoft Visual C++ 2012"

     Sim2



    If you receive errors during these steps run the command in verbose mode and check MATLAB is discovering MS Visual Studio:
    mex -setup -v

    Please also refer to the Mathworks® forums.

B. Rhapsody Configuration:

  1. Open the features window for a configuration you want to export with.
     
  2. Set the CPP_CG::MSVC::IDEVersion property to the MSVS version required.
    For example, pick "VC11" for the Visual Studio 2012 compiler.
     
  3. Set the CPP_CG::MSVC::CPU property to the architecture required. Note that Simulink 2016a and higher does not support 32bit.
    For example "amd64"

     rhp1
     
  4. If this is the first time using this IDEVersion and CPU in Rhapsody, you must rebuild the RhapsodyOXF framework. 
    Code menu > Build Framework. This will take a few minutes.
     
  5. Select the <<StructuredSimulinkBlock>> Block in your Rhapsody model, right click and from the context menu select one of the three export options:
     Export
  6. The exported Rhapsody model will open in Simulink®.

C. Export Errors and troubleshooting

If the export to Simulink fails a generic error message will be displayed in MATLAB:

SimErr

More information on the cause can be found in the IBM Engineering Systems Design Rhapsody output window (the same information is also written to a mex.log file located in the directory containing generated code for the configuration) 

  1. Wrong architecture selected:

    fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

    • If you are using MATLAB 2016b or higher this can only be incorrectly selected in IBM Engineering Systems Design Rhapsody.
    • Open the features for the configuration highlighted in bold in the Rhapsody browser.
    • Confirm the CPP_CG::MSVC::CPU property is set to "amd64"
       
  2. Mismatched _MSC_VER in IBM Engineering Systems Design Rhapsody:

    error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1700' in RhapSFunctionBlock....

    • The Microsoft Visual Studio® version selected in IBM Engineering Systems Design Rhapsody is higher than the version selected in MATLAB®. For example Microsoft Visual Studio® 2015 is selected in IBM Engineering Systems Design Rhapsody, MSVS2012 is selected in MATLAB®
    • To correct this in IBM Engineering Systems Design Rhapsody, modify the CPP_CG::MSVC::IDEVersion property
  3. Mismatched _MSC_VER in MATLAB:

    error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1900' in RhapSFunctionBlock....

    • The MSVS version selected in MATLAB® is higher than the version selected in IBM Engineering Systems Design Rhapsody. For example MSVS 2015 is selected in MATLAB®, MSVS2012 is selected in IBM Engineering Systems Design Rhapsody
    • To correct this in MATLAB®, run the command shown in Section A, step 1.
       
  4. No Supported Compiler or SDK was found
     
    • Compiler setup on MATLAB® has not been run for this installation. Please see Section A, step 1
    • To troubleshoot MATLAB® compiler setup, run the command in verbose mode and check MATLAB® is discovering Microsoft® Visual Studio®:
      mex -setup -v

Publication Number

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Component":"","Platform":[{"code":"PF033","label":"Windows"}],"Version":"8.1.5;8.2;8.2.1;8.3;8.3.1","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

ibm10715961