Why does Microsoft Visual Studio throw an error about "exceeded object file format limit" when I try to compile a model?

28 views (last 30 days)
I have a very large model and when I try to generate code and compile model, I get an error from Microsoft Visual Studio as below:
ERROR: error C1128: number of sections exceeded object file format limit : compile with /bigobj
NMAKE : fatal error U1077: '"c:\program files\microsoft visual studio 9.0\VC\BIN\cl.EXE"' : return code '0x1'
Stop.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 May 2023
Edited: MathWorks Support Team on 21 May 2023
This error is thrown if the object file is too large for Visual Studio to handle.
As workaround, pass the "/bigobj" flag to the compiler (see 
) in the makefile for the target.
There are two main ways of achieving this:
 
  1. I the model is using "ert_vc.tmf", then make a copy of this file and change the compiler options. Save the modified file with a different name on the MATLAB path and use it in the "Template makefile" option in the Code Generation pane of the model Configuration Parameters. For more information on template makefiles see the following page of the documentation:
  2. Create a custom '<STF>_make_rtw_hook' file, such that the flag "/bigobj" is automatically added to the compilation process during the "before_make", by following the documentation below and refer to the attached M-file:
Instead of modifying template makefiles or build hooks, you may find it easier to insert compiler directives in the model's configuration parameters:
NOTE
: Please do not modify any shipped file. If you need to customize it, always make a copy and then use the copy so that other models using the shipped file are not affected.
A long term solution for this issue would be to use Model Referencing in order to divide the model into smaller parts. As a result, smaller files are generated during code generation process and resources requirements during compile time are reduced.
For details on Model Referencing see:

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!