Contenuto principale

Use Custom Toolchain

This example shows how to use a previously registered custom toolchain (see Register Custom Toolchain) when generating a static or dynamic library or an executable file.

Note

You cannot use a custom toolchain to generate MEX functions. To specify a compiler for MEX-function generation, see Change the Default Compiler. If you want to modify the build process that produces the MEX function, modify the build information object. Use the PostCodeGenCommand configuration property to set the build arguments. For more information, see Build Process Customization.

  1. Use coder.config to create a configuration object. For example:

    cfg = coder.config('exe');
    

  2. Get the value of config(end).Name from the rtwTargetInfo.m file. Then assign that value to the cfg.Toolchain property:

    cfg.Toolchain = 'mytoolchain v#.#' | 'buildartifact (platform)'

  3. Perform other steps required to generate code, as described in Deployment. For example, specify the path and file name of the source code:

    cfg.CustomSource = 'filename_main.c';
    cfg.CustomInclude = pwd;
    

  4. When you generate code using the codegen function, specify the configuration object that uses the custom toolchain. For example:

    codegen -config cfg filename

You have completed the full workflow of creating and using a custom toolchain described in Custom Toolchain Registration.

See Also

|

Topics