Main Content

Troubleshoot Compiler Issues

Compiler Version Mismatch Errors

Description

The build process produces a compiler version mismatch error.

Action

  1. Check the list of supported and compatible compilers available at www.mathworks.com/support/compilers/current_release/.

  2. Upgrade or change your compiler. For more information, see Choose and Configure Compiler.

  3. Rebuild the model.

Results for Model Simulation and Program Execution Differ

Description

The program generated for the model produces different results from model simulation results. The generated source code includes an arithmetic operation that produces a signed integer overflow. It is possible that your compiler does not implement wrapping behavior for signed integer overflow conditions. Or, if you are using a compiler that supports wrapping, it is possible that you did not configure it to use the -fwrapv option.

For more information, see “Code Generator Relies on Undefined Behavior of C Language for Integer Overflows.”

Action

  • If your compiler can force wrapping behavior, turn it on. For example, for the gcc compiler or a compiler based on gcc, such as MinGW, specify the compiler option -fwrapv.

  • Choose a compiler that checks for integer overflows.

  • If you have Embedded Coder®, develop and apply a code replacement library to replace code generated for signed integers.

Generates Expected Code and Produces Unexpected Results

Description

The build process generates expected source code, but the executable program produces unexpected results. The generated source code appears as expected. However, the executable program produces unexpected results.

Action

Do one of the following:

  • Lower the compiler optimization level.

    1. Set the Compiler optimization level configuration parameter to Custom.

    2. In the Custom compiler optimization flags field, specify a lower optimization level.

    3. Rebuild the model.

  • Disable compiler optimizations.

    1. Set Compiler optimization level to Optimizations off (faster builds).

    2. Rebuild the model.

For more information, see Control Compiler Optimizations and your compiler documentation.

Compile-Time Issues

IssueAction

Error is present in the compiler configuration.

Make sure that MATLAB® supports the compiler and version that you want to use. For a list of currently supported and compatible compilers, see www.mathworks.com/support/compilers/current_release/. If necessary, upgrade or change your compiler (see Choose and Configure Compiler or Choose and Configure Compiler).

Environment variables are incorrectly set up for your make utility, compiler, or linker. For example, installation of Cygwin tools on a Windows platform affects environment variables used by other compilers.

Review the environment variable settings for your system by using the set command on a Windows platform or setenv on a Linux® platform. Make sure that the settings match what is required for the tools you are using.

Error is present in custom code specified as an S-Function block or in Custom Code. For example, the code refers to a header file that the compiler cannot find.

To isolate the source of the problem, remove the custom code from the model, debug, and rebuild the model.

The model includes a block, such as a device driver block, which is not intended for use with the currently selected system target file.

Remove the system target file-specific block or configure the model for use with another system target file.

A linker error about an undefined reference to the data appears when the model build generates an executable program from the model reference hierarchy and these conditions are true:

  • You represent signal, state, or parameter data by creating a data object such as Simulink.Signal. You use the object in a model reference hierarchy.

  • You use a custom storage class with the data object. Custom storage classes require Embedded Coder.

  • You set the owner of the object to a model that does not directly access the data.

  • You use the toolchain lcc-win64.

To resolve the issue, choose one of these methods:

  • In the data object, clear the Owner property. Alternatively, set the owner to a model that directly accesses the data.

  • Use a different toolchain, such as gcc, instead of lcc.

Note

The lcc-win64 compiler will be removed in a future release. For information about supported compilers, see https://www.mathworks.com/support/requirements/supported-compilers.html.

LCC Compiler Does Not Support Ampersands in Source Folder Paths

Description

If you use the LCC compiler and your model folder path contains an ampersand (&), the build process produces an error.

Action

Remove the ampersand from the model folder path. Then, rebuild the model.

LCC Compiler Might Not Support Line Lengths of Rapid Accelerator Code

Description

If you are compiling Rapid Accelerator code, the LCC compiler might produce an error related to line limits. Rapid Accelerator code can have longer line lengths due to obfuscation.

Action

Compile your Rapid Accelerator code using a compiler that supports longer code lines.

Related Topics

External Websites