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:
-
In the MATLAB® command window:
-
For C++ type:
mex -setup C++ -
For C type:
mex -setup
-
- MATLAB® will give a compiler status report:

Select the compiler required. For example "Microsoft Visual C++ 2012"
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:
- Open the features window for a configuration you want to export with.
- Set the CPP_CG::MSVC::IDEVersion property to the MSVS version required.
For example, pick "VC11" for the Visual Studio 2012 compiler.
- Set the CPP_CG::MSVC::CPU property to the architecture required. Note that Simulink 2016a and higher does not support 32bit.
For example "amd64"

- 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.
- Select the <<StructuredSimulinkBlock>> Block in your Rhapsody model, right click and from the context menu select one of the three export options:

- 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:
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)
- 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"
- 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
- 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.
- 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
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
ibm10715961