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

14 次查看(过去 30 天)
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. 

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2025-1-31
This error is thrown if the object file is too large for Visual Studio to handle.
As a workaround, pass the "/bigobj" flag to the compiler in the makefile for the target. Please follow the below link to find more information on the Fatal error: 
There are two main ways of achieving this:
 
  1. If 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. To find more information on custom compiler optimization flags in MATLAB R2020a, execute the following command in the command window to view the release-specific documentation:
>> web(fullfile(docroot, 'rtw/ref/custom-compiler-optimization-flags.html'))
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 the code generation process and resource requirements during compile time are reduced.
For details on Model Referencing see:
Please follow the below link to search for the required information regarding the lastest release:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by