Main Content

Use the Custom Toolchain

You can use a custom toolchain when generating a static or dynamic library or an executable. You cannot use one to generate MEX functions. To specify which compiler to use for MEX-function generation, seeSetting Up the C or C++ Compiler).

Before using the custom toolchain, register the custom toolchain, as described inRegister the Custom Toolchain.

  1. Usecoder.configto create a configuration object. For example:

    cfg = coder.config('exe');

  2. Get the value ofconfig(end).Namefrom thertwTargetInfo.mfile. Then assign that value to thecfg.Toolchainproperty:

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

  3. Perform other steps required to generate code, as described inDeployment. 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 thecodegenfunction, 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 inCustom Toolchain Registration.