What is the relationship between coder.config objects, registering a toolchain with RTW, and mex_C_glnxa64.xml?

BACKGROUND
  • I use MATLAB Coder.
  • After I create a custom toolchain and validate it, to register it I must create an object that appears to have a method called registerTargetInfo.
  • The name recommended for the function that creates this object is rtwTargetInfo.
  • I suspect that the rtw in rtwTargetInfo stands for Real-Time Workshop®, which is now known as Simulink Coder.
  • The mechanics of the toolchain registration is opaque to me, but it appears to me that MATLAB Coder can generate source-code without compiling it.
  • I thought that I had registered a custom toolchain properly, but when I let MATLAB Coder attempt the compilation step, too, it calls the wrong compiler. The path to this incorrect compiler appears only in the file mex_C_glnxa64.xml.
QUESTIONS
  • Must I update mex_C_glnxa64.xml by hand, or is there any relationship between this file and a custom toolchain?
  • What is happening when I register a custom toolchain?
  • Is there any way to link a coder.config object and a custom toolchain to give a more seamless view of the code-generation and compilation processes?

Answers (1)

Hello Joe,
For MEX code generation, MATLAB Coder will use the MEX compiler that has been selected (for instance via mex-setup). Custom toolchains are not supported for MEX code generation, they are only supported for standalone code generation. You can create a standalone code configuration object using the coder.config function with 'lib', 'dll', or 'exe' as the argument, and use the Toolchain and/or CustomToolchainOptions properties to link the config to your custom toolchain.
Here is a doc page that explains how to go about this, and also gives some insight into how the toolchain registration mechanism works: https://www.mathworks.com/help/coder/ug/adding-a-custom-toolchain.html
Hope this helps!

Categories

Products

Release

R2023a

Asked:

on 14 Jun 2023

Answered:

on 14 Jun 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!